Linchpin311 Thu Apr 30, 2009 10:53 pm
my last post, i feel was rushed so i will try and explain it a little more clearly.
like i said before you will probably need to execute two separate queries; one to tell you how many pages you will need and another to display however many rows per page (for this example, we'll say 10 rows per page).
lets say you have 28 rows to display... at 10 rows a page you will need 3 pages to display all of them. if this is the first page, your URL to get here should look like
www.example.com/?starting_row=0 and your "Next" link should look something like
www.example.com/?starting_row=10. if you say
$starting_row = $_GET['starting_row'] you can put the starting row in a variable.
then your query should probably look something like this
- Code:
$q = SELECT * FROM `example_table` LIMIT $starting_row,10;
this will return all rows from table "example_table" starting at whatever the variable $starting_row is set to and it will only return 10 at a time. understand?
on the second page your url should look like
www.example.com/?starting_row=10 cause thats what the "Next" link on the previous page looked like. on the second page, the "Next" link should be
www.example.com/?starting_row=20 (to get us to the third page) and the "Previous" link will be
www.example.com/?starting_row=0 (to get us to the first page). when you use GET to fetch the starting row before you execute the second query you can dynamically alter the query depending on which page you should be on... or really which rows you want to display!