PHP 简单分页代码


total_page     = 10;
$current_page   = empty($_GET['page']) ? 1 : $_GET['page'];
$previous_page  = $current_page - 1;
$next_page      = $current_page + 1;
 
if ($previous_page == 0) {
    $previous_page = 1;
}
 
 
if ($next_page > $total_page) {
    $next_page = $current_page;
}
 
echo "<a href="https://zhishitu.com/" target="_blank"> First Page </a>";
echo "<a href="https://zhishitu.com/" target="_blank"> Previous </a>";
 
for ($i=1; $i < $total_page; $i++) :
    if ($current_page == $i) {
        echo "<a href="https://zhishitu.com/" target="_blank"> $i - Selected </a>";
    }else{
        echo "<a href="https://zhishitu.com/" target="_blank"> $i </a>";
    }
 
endfor;
 
echo "<a href="https://zhishitu.com/" target="_blank"> Last Page </a>";
echo "<a href="https://zhishitu.com/" target="_blank"> Next </a>";
计算机