【发布时间】:2013-04-07 06:24:17
【问题描述】:
大家好,我正在尝试以以下格式创建分页
转到第 3 页 [文本框] 上一页 1 2 3 4 5 ....400 下一页
下面是我的代码
if(isset($_REQUEST['limit_start']) && $_REQUEST['limit_start'] > 0) $limit_start = $_REQUEST['limit_start'];
else $limit_start = 0 ;
if(isset($_REQUEST['results_to_show']) ) $results_to_show= $_REQUEST['results_to_show'];
else $results_to_show = 100;
if(($limit_start-$results_to_show)>=0)
$pagination.='<a href="details-inventory.php?limit_start='.($limit_start-$results_to_show).'&&results_to_show='.$results_to_show.'" >Previous</a> | ';
if (isset($_REQUEST['submit']) && $_REQUEST['submit'] != "")$search_limited = 1;
else $search_limited = 0;
global $wpdb;
$sql='SELECT count(*)
FROM `inventory_location` ';
$data= $wpdb->get_results($sql,ARRAY_A);
$row_count= $data[0]['count(*)'];
for($number=(($limit_start/$results_to_show)+1);$number<($row_count/$results_to_show);$number++)//($row_count/$results_to_show);$number++)($limit_start/$results_to_show)+
$pagination.= '<a href="details-inventory.php?limit_start='.($number*$results_to_show).'&&results_to_show='.$results_to_show.'" >'.$number.'</a> | ';
$pagination.= ' <a href="details-inventory.php?limit_start='.($limit_start+$results_to_show).'&&results_to_show='.$results_to_show.'" >Next </a> <br />';
现在的问题是...... 它显示了从 1 到最后一页的所有数字...我想将其分解为以下样式
1 2 3 4 5 ....400
感谢
【问题讨论】:
-
&&results_to_show这是一个错字吗?你到处都用过 -
@Atif Azad 你在使用 WordPress
-
是的,我正在使用 wordpress
标签: php wordpress pagination