What is wrong with this code?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Isabella
    New Member
    • Jan 2012
    • 3

    What is wrong with this code?

    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
    Code:
    <table border="0" cellpadding="2px" width="600px">
    		<?
    			$result=mysql_query("select * from products");
    			while($row=mysql_fetch_array($result)){
    		?>
        	<tr>
            	<td><img src="<?php=$row['picture']?>" /></td>
                <td>   	<b><?php=$row['name']?></b><br />
                		<?php=$row['description']?><br />
                        Price:<big style="color:green">
                        	$<?php=$row['price']?></big><br /><br />
                        <input type="button" value="Add to Cart" onclick="window.location='shoppingcart.php'" />
    			</td>
    		</tr>
            <tr><td colspan="2"><hr size="1" /></td>
            <? } ?>
        </table>
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    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?

    Comment

    • Isabella
      New Member
      • Jan 2012
      • 3

      #3
      No nothing shows. And when i run var_dump($row) it give me NULL.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        a strong indication that either your query fails or does not contain a result.

        Comment

        Working...