Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7820 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

Hello.

I have just begun working on tying a Filemaker database to the web using PHP and the FX.php tool. I'm very new at all this stuff and am just getting my feet wet, but I have a question that is PHP related. If anyone has used this method to get their database hooked up, I would love some help.

So, here is the situation

Database of photos with keywords

When you search for a keyword, the search result is a 4 x "however many necessary" table. I currently have it working so it just shows the images in one long table row, each image it finds it just adds another <td>img</td> section.

Using a loop, how do i make it just write 4 <td>'s and then close the row and start again?

my code is as follows.

<?php

include ("FX/FX.php");

include ("FX/prefs.php");

$FX = new FX ($FMAddress, $FMPort);

$FX->SetDBData('phdb.fp5', 'Web', 'All');

$FX->AddDBParam('keywords', 'football', 'eq');

$FX-> AddSortParam ('Name', 'Ascend');

$search = $FX-> FMFind();

if ($search['foundCount'] > 0)

{

echo "<table width=100%>";

echo "<tr>";

foreach ($search['data'] as $key => $value)

{

echo "<td><img src="http://$FMAddress:$FMPort/".$value['Image'][0]."" /></td>";

}

echo "</tr>";

echo "</table>";

}

else

{

echo "There Are No Search Results";

}

?>

I'm not sure if I am explaining this well as I'm having a hard time getting my head around it, but if anyone has any ideas I would really appreciate it.

Thanks very much

Noah

  • Newbies
Posted

how do you specify to only print 4 <td>s before either starting a new row or a new table?

i basically want a grid of images 4 wide by however long it has to be by the number of results, so 20 results would be 4 wide by 5 tall

i don't mind using cdml, but i couldn't figure out how to specify 4

Posted

Try this:

if ($search['foundCount'] > 0) 

{

echo "<table width=100%>"; 

echo "<tr>";

$i = 0; 

foreach ($search['data'] as $key => $value) 

{

$i += 1;

if ($i == 4)

   {

   echo "</tr><tr>";

   $i = 0;

   };

echo "<td><img src="http://$FMAddress:$FMPort/".$value['Image'][0]."" /></td>"; 

}

echo "</tr>"; 

echo "</table>"; 

}

else 

{

echo "There Are No Search Results"; 

}

Good Luck.

Garry

This topic is 7820 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.