我需要一个在我的分类网站上显示结果的公式。
我现在已经完成了记录的分页,但是这个显示结果的公式仍然存在。
我希望是这样的:
Showing 1-50 of 123 found.那么这个公式是什么呢?
我有这些变量,我认为这些变量应该足够了:
$results_per_page = 50; //results per page
$page = 1; //current page
Also a variable called $num_total contains the total nr of hits, in this case 123.谢谢
发布于 2010-05-08 23:53:12
这是你想要的吗?
<?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.';
?>https://stackoverflow.com/questions/2794667
复制相似问题