This PHP stuff is too cool! Thanks for getting me over the hump folks.
Here's my work in progress:
http://hills.ccsf.edu/~pfurma02/index.php?SCREEN=ecards.php
Only the 'next' button works for now but still I'm darn impressed with myself <g>. This will work on any folder of pictures with a subfolder of thumbs!
(source code below)
My question is, I'm updating the pages by creating a url back to the same script with some differing $_REQUEST settings for the page number (&PAGE=2) and on a smaller screen this bumps the page back to the top. Is there a better way to do this with some kind of update image function without getting into incompatible javascript or CSS or am I following normal procedure? Of course I'll want to be able to click each thumbnail to bring it into the big picture box, for now it's just displaying the first image on the page.
Here's another example of such a thing that leads me to believe I'm on the right track:
http://butterflies.bruciesusenetshit.info/butterflies
<?php $url = URL_DIR."index.php?SCREEN=ecards.php"; if (isset ($_REQUEST ['IMGDIR'])){ $imagedir=$_REQUEST ['IMG_DIR']; $subimagedir = $imagedir; # takes any url from the address bar # subimagedir is used for setting up relative urls # imagedir is for getting the directory listing } else { $subimagedir = 'grasses'; $imagedir = PUB_DIR . "/" . $subimagedir; # PUB_DIR global coordinates my public htm location at home & school } # get page for large sets if (isset ($_REQUEST ['PAGE'])){ $page=$_REQUEST ['PAGE']; } else {$page=1;} # verify page number after counting the pictures
# if the following is going to take an external url it'll need work if (!(chdir ($imagedir))){ print "invalid directory"; } $fh=opendir($imagedir); # extract & count pictures while ($file = readdir($fh)){ if (strstr ($file, '.jpg')){ $pictures[] = $file; } } # check picture sizes [LATER TASK] $thumbsize = 100; # verify if page number too high & loop back $pic_count = count($pictures); $pages = ($pic_count / 6); if ($page > $pages + 1) { $page = 1; $_REQUEST ['PAGE'] = "1"; } ?> <? # title row ?> <div style="font-size:200%"> Current gallery: <?php print $subimagedir ?><br> </div> <? # build the table ?> <center> <table width="100%" border=0> <? # navigation row and page number ?> <tr> <td align="right""> <a href="<?php print "$url&PAGE=$page"; ?>"> back </a> </td> <td align="center"> page: <?php print $page; ?> </td> <td align="left"> <a href="<?php #create a url with a page number one larger $next = ($page + 1); if ($next > $pages +1) # if too big, set back to 1 { $next = 1; $_REQUEST ['PAGE'] = "1"; }
print "$url&PAGE=$next"; ?>"> next </a> </td> </tr> </table> <table height="<?php $thumbsize ?>px" valign="center">; <tr> <?php # get six images for the given page # first picture in index based on current page $pic_num = ((6 * $page) -6);
# while the picture number has not exceeded # the current page # and total images while ($pic_num <= ((6 * $page) - 1) and ($pic_num <= $pic_count - 1)){ ?> <td> <? #print $pic_num . "   < "; #print ((6 * $page) - 1) . "   < "; #print ($pic_count - 1);####################
# create thumbnail image tags
?>
<img src="<?php print $subimagedir ?>/thumbs/<?php print $pictures[$pic_num] ?>"
alt="<?php print $pictures[$pic_num++] ?>" border=0>
<br>
</td>
<?php }
$pic_num = $pic_num - 6
?>
</tr>
</table>
<table>
<tr>
<td align="center"">
<?
# create large image tag
#need to verify pic_num in last or empty page
?>
<img src="<?php print "$subimagedir/$pictures[$pic_num]"; ?>"
alt="click to select this image" border=0>
</td>
</tr>
</table>
</center>
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php