- Impact
- 18
I am looking for some help to write a php pagination script.
Here is what I have at the moment. A mysql query that gets a list of results (dynamic, I can't tell how many results will be displayed). The script gets the "$p" variable from the query string, multiplies it by "10" and then that is used for the limit.
So, for instance:
($a is $p*10)
So, I know that every page will display 10 results, until, obviouslly, there are no results left.
$i is the number of rows on a the same query, but without the "LIMIT" clause.
I want to transfer this to a pagination thing, but only want a maximum of 10 links displayed (and next/previous).
(IE: <-- PREV - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - NEXT -->)
When you click next, if there are more than 10 pages, the 1 will disappear, and 11 will be displayed, and on and on, so no more than 10 number hyperlinks are displayed.
If anyone can help, I will be very grateful.
Thanks a lot!
Tom
Here is what I have at the moment. A mysql query that gets a list of results (dynamic, I can't tell how many results will be displayed). The script gets the "$p" variable from the query string, multiplies it by "10" and then that is used for the limit.
So, for instance:
Code:
SELECT * FROM pd_shops WHERE MATCH (name, description, keywords) AGAINS ('$q' IN BOOLEAN MODE) LIMIT $a, 10
So, I know that every page will display 10 results, until, obviouslly, there are no results left.
$i is the number of rows on a the same query, but without the "LIMIT" clause.
I want to transfer this to a pagination thing, but only want a maximum of 10 links displayed (and next/previous).
(IE: <-- PREV - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - NEXT -->)
When you click next, if there are more than 10 pages, the 1 will disappear, and 11 will be displayed, and on and on, so no more than 10 number hyperlinks are displayed.
If anyone can help, I will be very grateful.
Thanks a lot!
Tom






