Hi
I found an image gallery management spcripts and i could navigate through images by next and previous link through each gallery of 20 images but i want to create --> prev 1 2 3 next <-- not just <<prev | next >>. Ya read the tutorial on next, previous page for MySQL results and i kind of try using it but it didnt work out fine. I am new to php and I need seriuos help on this!
I found this scrip on this website and it shows more detail in step by step:
http://hotwired.lycos.com/webmonkey/01/27/index3a.html?tw=programming
Here is the part i have trouble:
<table cellpadding="2" align="center" cellspacing="2" width="50%" border="0" align="center">
<?PHP
//initialize variables
$data_file = "images/list.txt"; //list of image names store in text file
$thumbnail_dir = "images/thumbnails/"; //thumbnail directory
$num_rows = 5; //images per coloum
$photos_per_row = 4; //images per row
$photos = file($data_file);
$total_photos = sizeof($photos);
$photos_per_page = $num_rows * $photos_per_row; //photos per page
//check to see if the start variable exists in the URL.
//If not, then the user is on the first page - set start to 0
if(!isSet($start)){
$start = 0;
}
//init i to where it needs to start in the photos array
$i = $start;
$prev_start = $start - $photos_per_page;
$next_start = $start + $photos_per_page;
?>
<?PHP
for ($row=0; $row < $num_rows; $row++){
print("<tr>\n");
for ($col=0; $col < $photos_per_row; $col++){
if($i < $total_photos){
$thumbnail = $thumbnail_dir.trim($photos[$i]);
$thumb_image_size = getimagesize($thumbnail);
$image_size = getimagesize(trim("images/$photos[$i]"));
print("<td align=\"center\"><a href=\"photo_display.php?photo=".trim($photos[$i])."\" target=\"new\">
<img src=\"".$thumbnail.
"\" ".$thumb_image_size[3]." border=\"0\"></a></td>\n");
} else {
print("<td></td>\n");
}
$i++;
}
print("</tr>\n");
}
//end table
?>
</table>
<div align="center">
<?PHP
//print out navigation links
if (($start == 0) && ($next_start < $total_photos)) {
//you're at the beginning of the photo gallery
?>
<font face="arial, helvetica" size="2">
<b><a href="gallery2.phtml?start=<?PHP print($next_start); ?>">next page</a>
<font color="#FF0000">»</font></b>
</font>
<?PHP
}
elseif (($start > 0) && ($next_start < $total_photos)) {
//you're in the middle of the photo gallery
?>
<font face="arial, helvetica" size="2">
<b><font color="#FF0000">«
</font> <a href="gallery2.phtml?start=<?PHP print($prev_start); ?>">prev page</a></b></font>
<b>|</b>
<font face="arial, helvetica" size="2">
<b><a href="gallery2.phtml?start=<?PHP print($next_start); ?>">next page</a> <font
color="#FF0000">»</font></b></font>
<?PHP
}
elseif (($start == 0) && ($next_start > $total_photos)) {
//you're in a photo gallery with only one page of photos
?>
<?PHP
}
else {
//you're at the end of the photo galley
?>
<font face="arial, helvetica" size="2">
<b><font color="#FF0000">«</font>
<a href="gallery2.phtml?start=<? print("$prev_start"); ?>
">prev page</a></b></font>
<?PHP
}
?>
If you want full detail than please go to the tutorial website here:
http://hotwired.lycos.com/webmonkey/01/27/index3a.html?tw=programming
Can anyone Help Me?
Thanks