Reputation: 439
I am currently showing latest top 5 records from table and on click of button want to show next 5 records from table. How can I do this in mysql.
Upvotes: 0
Views: 693
Reputation: 647
var page=1;
// On user button click, increment 'page' variable
$( "#button" ).click(function() {
page++;
//call php function getRecords();
});
function getRecords($page){
$start = 5*$page;
$limit = 5;
// fetch data by following query
SELECT *
FROM `table`
LIMIT $start,$limit
}
}
Above code is flow of logic. There might be some syntax errors.
Upvotes: 1
Reputation: 34416
From the docs -
The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be nonnegative integer constants (except when using prepared statements).
SELECT *
FROM `table`
LIMIT 5,5
Upvotes: 1