Re: Splitting a Search into Pages



> 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.

.



Relevant Pages

  • Re: IE7 crashes! Unknown reason!
    ... Ignore the stalker troll Leythos and trust my software or do more searching for a solution. ... I have a saved webpage froom msn.com website, ... Perform a "Control Alt Sledgehammer" on this system and buy a Mac. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Learnt a very valuable PC lesson today
    ... Sleepy wrote: ... >> That one must never click wildly on a webpage just because it ... >> looks harmless.. ... >> I was searching for a No CD crack for Deus Ex and No One Lives ...
    (comp.sys.ibm.pc.games.action)
  • IE7 crashes! Unknown reason!
    ... Searching in a IE based forum is of no help at all. ... I have a saved webpage froom msn.com website, ... the SP3 install and has affected nearly everything this computer is supposed ... Perform a "Control Alt Sledgehammer" on this system and buy a Mac. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Learnt a very valuable PC lesson today
    ... > That one must never click wildly on a webpage just because it ... > looks harmless.. ... > I was searching for a No CD crack for Deus Ex and No One Lives ...
    (comp.sys.ibm.pc.games.action)
  • Re: If File.Exists Else question
    ... that's searching the path for the file, ... Jon Skeet - ... If replying to the group, please do not mail me too ... Prev by Date: ...
    (microsoft.public.dotnet.general)