Filter MySQL to display first 10 records per page
Posted: Wed Jul 20, 2011 8:16 am
Now that I have my template set up to display the contact of a MySQL database correctly via PHP I wish to edit the PHP used so it will on the first page display the first 10 records, and then I can create a second page for the next 10 results etc etc.
The PHP used is
Any help would be very useful.
Thank you very much.
The PHP used is
Code: Select all
<?php
mysql_connect('localhost', '**********', '***********') or die (mysql_error());
mysql_select_db('*********') or die (mysql_error());
$result = mysql_query("SELECT * from ********");
//Table starting tag and header cells
echo "<table border='0'><tr bgcolor='#adadad' align='center' valign='top'><th>Hire Code</th><th>Picture (click to enlarge)</th><th>Product Description</th><th>Hire Cost £ (Excl. VAT)</th>";
while($row = mysql_fetch_array($result)){
//Display the results in different cells
echo "<tr align='center' valign='top' bgcolor='#f0f0f0'><td>" . $row['productcode'] . "</td><td><img src='" . $row['picture'] . "' alt='image' /> </td><td>" . $row['description'] . "</td><td>" . $row['salesprice'] . "</td></tr>";
}
//Table closing tag
echo "</table>";
?>Thank you very much.