Page 1 of 1

Results 1 - 10 of 50

Posted: Wed Jun 23, 2004 6:19 pm
by zenabi
When a search is carried out in Google it shows something similar to this near the top of the page:

Results 1 - 10 of 50

I am having trouble working out how to do this (I have already implemented pagination).

From the example above (the search is limited to 10 results per page), 1 is simple to achieve, as is 50 (the total number of results), but I can't seem to figure out how to get the 10.

It's late and it's probably very simple to solve, so I am grateful to anyone who can help. Just the logic will be fine, but if it helps to explain your answer in php then it will be appreciated.

Cheers

Posted: Wed Jun 23, 2004 6:23 pm
by feyd
$start = ($pagenum-1) * $numperpage + 1;
$stop = $start + $numperpage - 1;

Posted: Wed Jun 23, 2004 6:23 pm
by Weirdan
If you implemented pagination perhaps there are variables in your code like

Code: Select all

$results_per_page; // constant or adjustable by user
  $start_result; // from request
  $total_results; // from query
so 10 is $start_result + $results_per_page - 1

Posted: Thu Jun 24, 2004 9:59 am
by zenabi
Thanks guys, much appreciated.