I have an order table in my database and once a user logs into his account, he/she can view his/her previous orders.
I have the following code for it:
<?php
$result = mysql_query("SELECT * FROM `order` WHERE username = '". $_SESSION['username']."' ")
or die(mysql_error()); ;
echo "<table border='0'><table border width=100%><tr><th>Product</th><th>Quantity</th><th>Price</th><th>Date</th>";
while($info = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $info['name']. "</td>";
echo "<td>" . $info['quantity']. "</td>";
echo "<td>" . $info['price']. "</td>";
echo "<td>" . $info['date']. "</td>";
}
echo "</tr>";
echo "</table>";
?>
what mysql statement do i use to show a message ‘you have not ordered anything yet’ instead of a blank table?
thanks
You could use
mysql_num_rows()to get the number of rows in the resultset.