我有一个分页问题,如何显示只有10个项目?在谷歌可以做这样的事情 - 数字增加了+5?分页php只有10个项目
<?php
// Make the links to other pages, if necessary.
if ($pages > 1) {
echo '<br /><p>';
$current_page = ($start/$display) + 1;
// If it's not the first page, make a Previous button:
if ($current_page != 1) {
echo '<a href="list_photos_4.php?s=' . ($start - $display) . '&p=' . $pages . '&sort=' . $sort . '">Previous</a> ';
}
// Make all the numbered pages:
for ($i = 1; $i <= $pages; $i++) {
if ($i != $current_page) {
echo '<a href="list_photos_4.php?s=' . (($display * ($i - 1))) . '&p=' . $pages . '&sort=' . $sort . '">' . $i . '</a> ';
} else {
echo $i . ' ';
}
} // End of FOR loop.
// If it's not the last page, make a Next button:
if ($current_page != $pages) {
echo '<a href="list_photos_4.php?s=' . ($start + $display) . '&p=' . $pages . '&sort=' . $sort . '">Next</a>';
}
echo '</p>'; // Close the paragraph.
} // End of links section.
?>
你好,谢谢你的回复我现在有类似的内容SCREAM:错误抑制忽略注意:Undefined variable:i in C :\ wamp \ www \ dwwithphp \ public \ admin \ list_photos_4.php on line 186 - line 186“if($ i!= $ current_page){” –
@ Mantykora7刚把我的解答放到for循环中:for($ i = 1 ; $ i <= $ pages; $ i ++){// MY ANSWER HERE} 我刚编辑我的答案。应该工作 – Adam
是的,你是对的,粘贴错误的东西,效果很好,谢谢你的时间和回答:) –