$current_page and $total_pages will be filled with the respected values, so 32 and 174 would work fine.
If you had 2000 pages and you were on page... hmm, 1, you would see...
[Page 1 of 2000] [1] [2] [3] [11] [51] [101] [501] ... [>] [Last >>]
And if you were on page 77 you would see
[Page 77 of 2000] [<< First] [<] ... [75] [76] [77] [78] [79] [89] [129] [177] [577] ... [>] [Last >>]
But I realised I still need to add milestones for going backwards, so the beginning of the above example should look like this;
[Page 77 of 2000] [<< First] [<] ... [27] [67] [75] [76] [77] etc
If I wanted to add extra milestone buttons this would be simple, but the website I am making this for won't have more than 500 pages, since this is for a small image gallery.
Edit: Pseudo code for backward milestones:
PHP Code:
if ($current_page > 500) {
//$current_page - 500;
}
if ($current_page > 100) {
//$current_page - 100;
}
if ($current_page > 50) {
//$current_page - 50;
}
if ($current_page > 10) {
//$current_page - 10;
}
This would come straight after the first switch statement.
Another Edit: Here is my pseudo code that I have converted so that it should work, still need to test it though, oh, and I need to make it actually show the images on the current page too.
PHP Code:
<?
include 'includes/SQL_connect.php';
$current_page = $_POST['page'];
$result = mysql_query("SELECT * FROM images");
$total_pages = mysql_num_rows($result);
if ($total_pages > 1 && $current_page <= $total_pages && $current_page > 0) {
echo '<div id="page_numbers"><ul>'; //beginning page number section
echo '<li><img src="ui_images/down.png"> Page '.$current_page.' of '.$total_pages.'</li>'; //page x of y
switch ($current_page) {
case 1:
case 2:
case 3:
case 11:
case 51:
case 101:
case 501:
break;
default:
echo '<li><img src="ui_images/dleft.png"> First</li>'; //first button
break;
}
if ($current_page > 1) {
echo '<li><img src="ui_images/left.png"></li>'; //left arrow
}
if ($current_page >= 4) {
echo '...'; //dots
}
if ($current_page > 500) {
echo '<li>'.($current_page - 500).'</li>'; //$current_page - 500;
}
if ($current_page > 100) {
echo '<li>'.($current_page - 100).'</li>'; //$current_page - 100;
}
if ($current_page > 50) {
echo '<li>'.($current_page - 50).'</li>'; //$current_page - 50;
}
if ($current_page > 10) {
echo '<li>'.($current_page - 10).'</li>'; //$current_page - 10;
}
if ($current_page >= 3) {
echo '<li>'.($current_page - 2).'</li>'; //$current_page - 2;
echo '<li>'.($current_page - 1).'</li>'; //$current_page - 1;
}
echo '<li id="selected_page">'.$current_page).'</li>'; //$current_page;
if (($total_pages - $current_page) >= 2) {
echo '<li>'.($current_page + 1).'</li>'; //$current_page + 1;
echo '<li>'.($current_page + 2).'</li>'; //$current_page + 2;
}
if ($total_pages >= ($current_page + 10)) {
echo '<li>'.($current_page + 10).'</li>'; //$current_page + 10;
}
if ($total_pages >= ($current_page + 50)) {
echo '<li>'.($current_page + 50).'</li>'; //$current_page + 50;
}
if ($total_pages >= ($current_page + 100)) {
echo '<li>'.($current_page + 100).'</li>'; //$current_page + 100;
}
if ($total_pages >= ($current_page + 500)) {
echo '<li>'.($current_page + 500).'</li>'; //$current_page + 500;
}
if ($current_page < $total_pages) {
if (($total_pages - $current_page) > 2) {
echo '...'; //dots
}
echo '<li><img src="ui_images/right.png"></li>'; //right arrow
switch ($total_pages - $current_page) {
case 1:
case 2:
case 10:
case 50:
case 100:
case 500:
break;
default:
echo '<li>Last <img src="ui_images/dright.png"></li>'; //last button
break;
}
}
echo '</ul></div>';
}
?>
Once again, another edit: herp derp, $total_pages will be the number of rows, not the number of pages
I need to do $total_pages = $number_of_rows / $number_of_images_per_page; will fix soon if anyone actually cares
Bookmarks