Paging system help
Posted: Sun Sep 12, 2010 6:52 pm
Hey ya guys. I've been working on paging system for an image gallery and I'm having trouble adding a next and previous page link. I think my theory craft on it my be off some.
What I'm having trouble with is figuring out where, or how I should put in a next and previous link so make it a little more user friendly.
Any thoughts, or other questions?
Code: Select all
$images_per_page = 16
//$file_names is a function to get the images of the current working dir in an array
//The javascript:showpage function is how I'm passing a few variables into/out of java, but in this case the value is the image off set. Example page 1=0, page 2=16, page 3=32, and so on.
if ((count($file_names)>$images_per_page || isset($_REQUEST['showimage'])) && $order==0) {
if ($albumpage==1)
echo "Page <font color=red>1</font>";
else
echo "Page <a href=\"javascript:showpage(0)\"><u>1</u></a>";
}
if ($order==0) {
for ($i=$images_per_page;$i<count($file_names);$i+=$images_per_page) {
$p=ceil($i/$images_per_page)+1;
if ($albumpage==$p)
echo " | <font color=red>$p</font>";
else
echo " | <a href=\"javascript:showpage($i)\"><u>$p</u></a>";
}
}
//OUTPUT EXAMPLE: "Page 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15"
//What I'm trying to get (assume not on first or last page): "Page [PREVIOUS] 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 [NEXT] Any thoughts, or other questions?