By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,586 Members | 992 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,586 IT Pros & Developers. It's quick & easy.

What is wrong with this code?

P: 3
I'm making shopping cart, and I have s problem displaying the products. Here's a part of the code where I think the problem is. I'm using xampp. Is something wrong with the query? Please help, Thanks
Expand|Select|Wrap|Line Numbers
  1. <table border="0" cellpadding="2px" width="600px">
  2.         <?
  3.             $result=mysql_query("select * from products");
  4.             while($row=mysql_fetch_array($result)){
  5.         ?>
  6.         <tr>
  7.             <td><img src="<?php=$row['picture']?>" /></td>
  8.             <td>       <b><?php=$row['name']?></b><br />
  9.                     <?php=$row['description']?><br />
  10.                     Price:<big style="color:green">
  11.                         $<?php=$row['price']?></big><br /><br />
  12.                     <input type="button" value="Add to Cart" onclick="window.location='shoppingcart.php'" />
  13.             </td>
  14.         </tr>
  15.         <tr><td colspan="2"><hr size="1" /></td>
  16.         <? } ?>
  17.     </table>
Jan 28 '12 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 5K+
P: 8,639
Is something wrong with the query?
not syntax-wise but the * (wildcard) character should be avoided since it will give you a hard time in debugging.

while Iím at debugging, does your query succeed, at all?
Jan 29 '12 #2

P: 3
No nothing shows. And when i run var_dump($row) it give me NULL.
Jan 29 '12 #3

Expert Mod 5K+
P: 8,639
a strong indication that either your query fails or does not contain a result.
Jan 29 '12 #4

Post your reply

Sign in to post your reply or Sign up for a free account.