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 " First Page "; echo " Previous "; for ($i=1; $i < $total_page; $i++) : if ($current_page == $i) { echo " $i - Selected "; }else{ echo " $i "; } endfor; echo " Last Page "; echo " Next ";