Re: Splitting a Search into Pages
- From: basement_addict@xxxxxxxxx
- Date: 2 Sep 2005 15:50:52 -0700
> BUT.... if I want to split the search into groups of 10 and then (like
> Google) prompt for page 2 of 10, 3 of 10 etc.
>
Here is the way I go about it. It might work for you.
//constant number of results per page.
$pagesize=25
//start at 0 then pass in $page=[some number] in the url.
$currentpage=3
//calculate number to skip by multiplying what page you are on
//by the page size.
$skip = $currentpage * $pagesize
//use calc_found_rows in mysql select and mysql will calculate
//the result count regardless of the limit in the sql
select calc_found_rows * from table where limit $skip, $pagesize
//use "select found_rows()" after running the above query
//and assign to $totalcount
$totalcount=150 // assigned from "select found_rows()"
Take $totalcount (150 in this case) divided by $pagesize (25) to get
the max number of pages to display on the page (6 in this case).
Create links on the webpage that pass in the page number.
1 2 3 4 5 6
example url
<a href="/webpage.php? ... &page=5">5</a>
where ... is the query string of what the user was searching on
This is not complete but should be enough to get you going somewhere.
.
- Follow-Ups:
- Re: Splitting a Search into Pages
- From: Alec
- Re: Splitting a Search into Pages
- References:
- Splitting a Search into Pages
- From: Alec
- Splitting a Search into Pages
- Prev by Date: Re: passing form data to an email address/Excel sheet on a local computer
- Next by Date: Re: passing form data to an email address/Excel sheet on a local computer
- Previous by thread: Re: Splitting a Search into Pages
- Next by thread: Re: Splitting a Search into Pages
- Index(es):
Relevant Pages
|