开发者

MySql paging; "Showing result-set" of "total found" help

I need a formula for showing results on my classifieds website.

I am now done with the paging of records, but this formula for showing results remains.

I want it like this:

  Showing 1-50 of 123 found.

Now what is the formula for this?

I have these variables which should be enough I think:

  $results_per_page =开发者_Python百科 50; //results per page
  $page = 1; //current page
  Also a variable called $num_total contains the total nr of hits, in this case 123.

Thanks


Is this what you want?

<?php

$page = 1;
$results_per_page = 50;
$num_total = 123;

echo 'Showing ' . ((($page - 1) * $results_per_page) + 1)
                . '-' . min($num_total, ($page * $results_per_page))
                . ' of ' . $num_total . ' found.';

?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜