Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
Thread Tools Display Modes
Share |
  #1  
Old 07-13-2009, 10:29 PM
gilbertsavier gilbertsavier is offline
Junior Member
 
Join Date: 06-29-09
Posts: 19
iTrader: 0 / 0%
PHP loop through database and limit number of entries

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:

<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=\"http://www.v7n.com/forums/images/catalog/ottomans/thumbs/$chairImage\" width=\"157\" height=\"147\" />";
echo "<br />";
echo $chairName;
echo "</td>";
echo "</tr>";


}

--------------------
Thanks & regards
Lokananth
Live chat By miOOt

Last edited by HTMLBasicTutor; 07-13-2009 at 11:09 PM.
 
Reply With Quote

Advertisement

Advertisement

  #2  
Old 07-14-2009, 10:22 AM
HTMLBasicTutor's Avatar
HTMLBasicTutor HTMLBasicTutor is offline
Administrator
 
Join Date: 10-29-07
Location: Canada
Posts: 26,710
iTrader: 5 / 100%
What's your question?
 
Reply With Quote
  #3  
Old 07-14-2009, 03:35 PM
zeronese zeronese is offline
Junior Member
 
Join Date: 07-14-09
Posts: 23
iTrader: 0 / 0%
depending on how you are retriving the information, you might want to try this:

when you enter the for loop,
PHP Code:
$j $i-1//only needed becuase $i is starting from 1
if(($j 4) == 0)
echo 
"<tr>";
if((
$j 3) == 0)
echo 
"</tr>"
Good Luck
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to retrieve the total number of rows when using LIMIT X, XXX yangyang Coding Forum 3 09-21-2008 06:27 PM
SQL Loop Help, Please JohnRogers Coding Forum 1 01-21-2007 12:27 PM
Number 1 baby, number 1, whoooooooooo! Simon - 1977 Google Forum 4 05-08-2004 02:23 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 05:36 PM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC