Jump to content

PHP loop through database and limit number of entries


gilbertsavier

Recommended Posts

Hi,

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:

 

My First Row

My First Row 2

My First Row 3

 

My Second Row

My Second Row 2

My Second Row 3

 

 

 

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 "

echo "

";

echo "$chairImage\"";

echo "

";

echo $chairName;

echo "

";

echo "

";

 

 

}

 

 

------------------------------------

Thanks & regards

Lokananth

Link to comment
Share on other sites

"I need it to only display 3 td tags per line and then move on to the row."

 

This is bound by the recordset you are pulling from the database - each loop allows you to print out one record from MySQL. So if your record is made up of three columns/fields you will get three

pairs.

 

Does this make sense?

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...