ashton321 Posted November 7, 2008 Share Posted November 7, 2008 Hi all. I would like to make a page that displays the image the name and the price with only 3 cells per row then have the script automatically go to the next row but the only solution i can come up with to get 3 on a row is to use a for loop that maxes out at 3 the start the next row at 4. I dont want to have to do this because when i add more items i need to edit the inventory page as well. here is the inventory page code <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Flower Inventory</title> </head> <?php include ('header.html'); $dbcnx = mysql_connect('dbxxxxxx', 'xxxxxx', 'xxxxxx'); mysql_select_db('dbxxxxxxxx'); $flower = mysql_query('SELECT id, name, price, info, event, color, piclink FROM flower_inventory'); ?> <table width ="885" align="center" > <tr><?php for ($i=1; $i<=3; $i++) { $row = mysql_fetch_array($flower)?> <td width="400"><center><a href="viewproduct.php?id=<?php echo $row['id'] ?>"><img border="4" src="images/flowers/<?php echo $row['piclink'] ?>"> </img><br /> <strong><font face="Verdana" size=3.5 color="330066"> <?php echo $row['name'] ?></a></center><br />        <?php echo $row['price'] ?></strong></font></td> <?php } ?> </tr><tr><td><br /></td></tr> <tr><?php for ($i=4; $i<=6; $i++) { $row = mysql_fetch_array($flower)?> <td width="400"><center><a href="viewproduct.php?id=<?php echo $row['id'] ?>"><img border="4" src="images/flowers/<?php echo $row['piclink'] ?>"> </img><br /> <strong><font face="Verdana" size=3.5 color="330066"> <?php echo $row['name'] ?></a></center><br />        <?php echo $row['price'] ?></strong></font></td> <?php } ?> </tr> </table> </body> </html> it displays what i want currently at fblaflowers.com/inventory.php but if i use a while loop it chruchs all the cells into one row. please help me. Link to comment https://forums.phpfreaks.com/topic/131731-solved-creating-html-table-from-sql-database/ Share on other sites More sharing options...
trq Posted November 7, 2008 Share Posted November 7, 2008 See here. Link to comment https://forums.phpfreaks.com/topic/131731-solved-creating-html-table-from-sql-database/#findComment-684266 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.