Jump to content

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>
      

 

 

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.