Jump to content

Recommended Posts

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 />
   &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<?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 />
   &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<?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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.