Prad,
First you need to know the total no of rows in your Select query in your example:
$con = mysqli_connect($host, $username, $password, $databasename);
$sql = "SELECT * FROM tablename";
$rst = $con->query($sql);
$num_rows = $rst->num_rows;
// Assuming you want to show 3 record ins a page:
$offset = 0;
$limit = 3
SELECT Id, Name, Percentage
FROM tablename
LIMIT $offset, $limit;
// create a script to show your example here:
// Your footer:
// Create the 'previous' link
if ($offset > 0) {
$prev = $offset - $limit;;
$url = $_SERVER['PHP_SELF']."?offset=$prev";
echo "<a href=\"$url\">Previous</a> ";
}
// Create the 'next' link
if ($offset < ($num_rows-$limit)) {
$next = $offset + $limit;
$url = $_SERVER['PHP_SELF']."?offset=$next";
echo "<a href=\"$url\">Next</a>";
}
enjoy
|