co.ador Posted March 26, 2011 Share Posted March 26, 2011 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> Link to comment https://forums.phpfreaks.com/topic/231776-what-is-the-problem-with-this-while-loop-and-table/ Share on other sites More sharing options...
sasa Posted March 26, 2011 Share Posted March 26, 2011 change ... $dynamicList = '<table width="100%" ... to ... $dynamicList .= '<table width="100%" ... Link to comment https://forums.phpfreaks.com/topic/231776-what-is-the-problem-with-this-while-loop-and-table/#findComment-1192533 Share on other sites More sharing options...
co.ador Posted March 26, 2011 Author Share Posted March 26, 2011 Thank you appendding the variable made it thanks you very much sasa. Co.ador Link to comment https://forums.phpfreaks.com/topic/231776-what-is-the-problem-with-this-while-loop-and-table/#findComment-1192552 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.