Newbies salparadi Posted June 18, 2003 Newbies Posted June 18, 2003 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 salparadi Posted June 18, 2003 Author Newbies Posted June 18, 2003 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
Garry Claridge Posted June 19, 2003 Posted June 19, 2003 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now