" method="GET"> ">
'; if ($current_page > 1) { echo '<'; } echo "" . ($current_page == 1 ? "1" : 1) . ''; $max = 5; $range = 2; $start = max(2, $current_page - $range); $end = min($total_pages - 1, $current_page + $range); if ($current_page <= $range) { $start = 2; $end = min($total_pages - 1, $max); } if ($current_page > $total_pages - $range) { $start = max(2, $total_pages - $max); $end = $total_pages - 1; } if ($start > 2) { echo '...'; } for ($i = $start; $i <= $end; $i++) { echo ""; echo $i == $current_page ? "$i" : $i; echo ''; } if ($end < $total_pages - 1) { echo '...'; } echo "" . ($current_page == $total_pages ? "$total_pages" : $total_pages) . ''; if ($current_page < $total_pages) { echo '>'; } echo ''; }