I am trying to make a simple stock exchange application in PHP and have a completely working session-based login system. Now I am having an issue listing the stocks a user has in a table. When I run the exact query that I have made in my PHP code in Navicat, the query returns the desired results, but PHP will not use the information to populate the table. The 0 in current value is a placeholder until I implement the YQL code required to pull stock information. I have a screenshot showing just about everything necessary to view what I am talking about:
My PHP code for the query is here:
echo "Welcome to your portfolio overview. Here you can view many of your statistics.<br><br><b>Balance:</b> " . $balance . "<br><b>Debt:</b> " . $debt . "<br>";
$sql2 = "SELECT * FROM `trades` WHERE buyerid=$uid";
$result2 = mysql_query($sql2);
echo "<table border=2 cellpadding=5>";
echo "<tr><td><b>Symbol</b></td><td><b>Purchase Price</b></td><td><b>Current Value</b></td></tr>";
while($row2 = mysql_fetch_array($result2));
{
echo "<tr><td>" . $row2['identifier'] ."</td><td>" . $row2['purchaseprice'] . "</td><td>" . 0 . "</td></tr>";
}
echo "</table>";

You have an erroneous semicolon after the
whilecondition:With this semicolon in place, you loop over an empty statement until your resultset is exhausted and then you execute the
echostatement contained within your braces (with$row2now false) irrespective of thewhileloop before.