Ok, first:Here's how to handle previous/next, first and last (including the code I postd before...)
$total_pages = $total_count / $per_page;if ($total_pages > 1) { $tags = array(); if ($page == 1) { $tags[] = array( '<span class="disabled_page">', '</span>' ); $tags[] = array( '<span class="disabled_page">', '</span>' ); } else { $tags[] = array( '<a href="viewtopic.php?id=' . $id . '&page=1">', '</a>' ); // First $tags[] = array( '<a href="viewtopic.php?id=' . $id . '&page=' . ($page - 1) . ">', '</a>' ); // Previous } echo $tags[0][0] . '<< First' . $tags[0][1] . ' '; echo $tags[1][0] . '< Previous' . $tags[1][1] . ' ';}for ($i=1; $i <= $total_pages; $i++) { if ($i == $page) echo '<span class="disabled_page">'; // changed the class else echo '<a href="viewtopic.php?id=' . $id . '&page=' . $i .'">'; echo $i; if ($i == $page) echo '</span>'; else echo '</a>'; echo ' ';}if ($total_pages > 1) { $tags = array(); if ($page >= $total_pages) { $tags[] = array( '<span class="disabled_page">', '</span>' ); $tags[] = array( '<span class="disabled_page">', '</span>' ); } else { $tags[] = array( '<a href="viewtopic.php?id=' . $id . '&page=' . $total_pages . '">', '</a>' ); // Last $tags[] = array( '<a href="viewtopic.php?id=' . $id . '&page=' . ($page + 1) . ">', '</a>' ); // Next } echo $tags[1][0] . 'Next >' . $tags[1][1] . ' '; echo $tags[0][0] . 'Last >> . $tags[0][1] . ' ';}
That's not perhaps the perfect example/code (from a visitors p.o.v.), but it works fine...