我在php中的分页代码只列出没有控制权的页面,如果我有100个页面,它会列出100个没有缩短的说法,例如1 2 3 ... 98 99 100,但是它会从1到100列出它而没有缩写,这是我的分页代码:
<?php
$result = $myApp->dbTransaction("SELECT * FROM cause_lists;");
$getNum = mysql_num_rows($result);
$pg = $getNum/10;
$rem = ($getNum%10)/10;
if ($rem > 0) {
$pg -=$rem;
$pg +=1;
}
if ($pg == 2 || $pg > 2){
$page_num = $pg;
}
if (!empty($page_num)){
if ($range_filter === 0){$arrow_class_1 = "arrow unavailable";
$arrow_link_1 = "#";
}
else {$arrow_class_1 = "arrow";
$r = $range_filter + 0;
$arrow_link_1 ="cl_admin.php?range=$r";
}
if ($range_filter != (($pg * 10) - 10)) {$arrow_class_2 = "arrow"; $arrow_link_2 ="#";
$r = $range_filter + 20;
$arrow_link_2 ="cl_admin.php?range=$r";
}
else {$arrow_class_2 = "arrow unavailable";
$arrow_link_2 ="#";
}
echo " <ul class=\"pagination\"><li class=\"$arrow_class_1\"><a href=\"$arrow_link_1\">«</a></li>";
for($i=1; $i<=$page_num; $i++){
$rge = $i * 10;
if(($range_filter+10) === $rge){$page_class = "current";} else {$page_class = "";}
echo "<li class='$page_class'><a href=\"cl_admin.php?range=$rge\">$i</a></li>";
}
echo "<li class=\"$arrow_class_2\"><a href=\"$arrow_link_2\">»</a></li></ul>";
}
?>
答案 0 :(得分:0)
抱歉,该文件是泰语,但我相信您可以轻松理解。
设置$ config ['num_links']以显示可见的页数。