Jump to content

what is the problem with this while loop and table?


co.ador

Recommended Posts

There is only one row out of 7 rows in the database displaying in the table. I have debug the code bug it keeps displaying only one results? I know it should be some problem with the table and not with the while loop or the other way around. help!

 

<?php
$dynamicList = "";
$sql= mysql_query("SELECT * FROM products ORDER BY date_added DESC");
$productCount = mysql_num_rows($sql); 
if ($productCount>0 )
     {
while($row = mysql_fetch_array($sql))
           {
       $id= $row["id"];
       $product_name= $row["product_name"];
       $price = $row["price"];
       $date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
               $dynamicList = '<table width="100%" border="0" cellpadding="6" cellspacing="0"> 
                                         <tr>
                                           <td width="17%" valign"top"><a href="product.php?id='.$id.'"><img style="boder:#666 1px solid",                 src="inventory_images/'.$id.'.jpg" alt="'.$product_name.'" width="90%" height="102" border="0" /></a></td>
                                           <td width="65%" valign="top">'.$product_name.'<br />$'. $price . ' <br />
                                            <a href="product.php?id='.$id.'">View Product Details</a></td></tr></table>';
      }
  }  
else {
            $dynamicList = "We have no products listed in your store yet";  
      } ?>    


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Store Home Page</title>
<link rel="stylesheet" href="style/style.css" type="text/css" media="screen" />
</head>
<body>
<div id="pageContent">

  <table width="100%" border="0" cellspacing="0" cellpadding="10">
   <tr>
    <td width="131" height="92" valign="top">some crap</td>
      <td width="112" valign="top"><p>Newest items Added to the Store</p>
        <p><?php echo $dynamicList; ?><br /></p>
       </td>
     <td width="84" valign="top">More Crap</td> 
   </tr>
  </table>

</div>
</body>
</html>
      

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.