I have a table, in this table I have 20 columns, My default value starts from 2-11 displaying only 10 results. When the user clicks the previous button, I want to display the previous 1-10 result. How can I achieve this?
You have to send page as parameter to get paginating. Rest is easy. In SQL you have LIMIT clause which gets data limited to limit and offset variables you set. Example:
You have a table with 100 rows. If you want to get first 10 you have to write something like:
SELECT columns FROM table ... LIMIT 0,10
if you want to get next 10 rows the query should be
SELECT columns FROM table ... LIMIT 10,10
And so on
page Parameter shows what page you are displaing and offset is easy to calculate from it.
$offset = $currentPage*$limit;