Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 31st, 2009, 06:42 AM
Authorized User
 
Join Date: Jun 2009
Posts: 12
Thanks: 0
Thanked 1 Time in 1 Post
Default PHP loop through database and limit number of entries

Hello,
Going to try to explain this as best I can. I have a bunch of stuff in a database and I need to display this info within a table. This isn't a problem at all but, I need it to only display 3 td tags per line and then move on to the row.

so i need it to do :

code:

<table>
<tr>
<td>My First Row</td>
<td>My First Row 2</td>
<td>My First Row 3</td>
</tr>

<tr>
<td>My Second Row</td>
<td>My Second Row 2</td>
<td>My Second Row 3</td>
</tr>
</table>



and continue to do this through every entry in the database table.

so I have something like this that will display the info:

code:

for ($i = 1; $i <= $num; $i++){

$chairArray = mysql_fetch_array($chairResult);
$chairName = $chairArray['name'];
$chairDescription = $chairArray['description'];
$chairImage = $chairArray['image'];

echo "<tr>";
echo "<td>";
echo "<img src=\"images/catalog/ottomans/thumbs/$chairImage\" width=\"157\" height=\"147\" />";
echo "<br />";
echo $chairName;
echo "</td>";
echo "</tr>";


}
__________________
Thanks & regards
Lokananth
[url "http://www.mioot.com"]Live Chat Software[/url] By miOOt





Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to print out database entries... Teessider_2000 Beginning PHP 0 June 29th, 2007 02:58 PM
for-each loop predefined number of times vonkeldoos XSLT 1 February 22nd, 2007 07:47 AM
Loop issue - with n number of same nodes.. ramesh.kumarm XSLT 3 March 8th, 2006 08:19 AM
put a limit on the number of characters entered in crmpicco HTML Code Clinic 6 April 12th, 2005 06:08 AM
Forms and Database Entries hcweb Classic ASP Basics 3 June 4th, 2004 10:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.