Hi all,
I’m having a bit of trouble figuring out how to do this loop. I want to display in a table just the 5 most recent entries into the database. When I try to do this with a for or while loop it just spits out the first entry 5 times. What’s the best way to do this? Here is the code:
<?php
$db = mysql_select_db("serial");
$sql = "SELECT id, customer, product, motherboard, firmware, serial, warranty FROM entries ORDER BY id ASC";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$id = $row['id'];
$customer = $row['customer'];
$product = $row['product'];
$motherboard = $row['motherboard'];
$firmware = $row['firmware'];
$serial = $row['serial'];
$warranty = $row['warranty'];
while($i<5){
echo "<tr>";
echo "<td>" . $customer . "</td> <td>" . $product . "</td> <td>" . $motherboard . "</td> <td>" . $firmware . "</td> <td>" . $serial . "</td> <td>" . $warranty . "</td>";
echo "</tr>";
$i++;
}
?>
Thanks