CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Jan 2012
    Posts
    5

    I have a problem with mysql database!

    Hi I'm making shopping cart and i have a problem displaying the products from the database. The language is PHP and here's a part of the code where I think the problem is? Can you help me? 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>

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: I have a problem with mysql database!

    Two problems right off.

    1. You should always use the full <?php tag opening. Not all servers have short tags enabled.

    2. You're not using echo. You're simply using =$row....
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured