The assignment is: Change your fruit order form to construct the table of names, prices and weights by extracting the items from the database rather than hard-coding them. Display every item from the database. Do not assume that you know the number of items. I am having problems because of something in my if statement or it might be my while loop. I don't know exactly what I am doing wrong and I need some help trying to figure this out.
<table>
<th>Fruits For Sale!</th>
<tr><th>Fruits</th><th>Weight</th><th>Price</th></tr>
<?php
$db=mysqli_connect(null,null,null,'weblab')
or die("Can't connect to DB:" . mysqli_connect_error());
$q = "select fruit_item_no, fruit_name, fruit_weight, fruit_price";
$q .= "from fruit_t";
$q .= "order by fruit_name;";
$dbResult = mysqli_query($db,$q)
if ($num == 0) {
echo '<tr><td colspan="2">';
echo 'Database query retrieved zero rows.</td></tr>';
}
while ($row = mysqli_fetch_assoc($dbResult)) {
$name = $row['fruit_name'];
$weight = $row['fruit_weight'];
$price = $row['fruit_price'];
echo "<tr><td><b>$name</b></td>";
echo "<td>$weight</td>";
echo "<td>$price</td></tr>\n";
}
?>
</table>