Forum Moderators: coopster

Message Too Old, No Replies

Using loops or SOMETHING for an image "rotator"

I'm having trouble with my screenshots section

         

bohsocks

3:12 pm on May 23, 2004 (gmt 0)



I run a Zelda website and for the screenshots section I have thumbnails of a number of screennames that show up, as well as the #'s of the ones that do not. Upon clicking on either a thumb or a number the image pops up in full size into another window via a php file. I would like to be able to have this happen and also have the file be recognized and be able to have Previous and Next buttons without having to imput all the information about the files into the page. Is there some way I can have the page recognize the filename and do some kind of -1 +1 thing to the filenames (ex. zelda101.jpg +1 zelda102.jpg) and be able to move on from there?

isitreal

5:20 pm on May 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you have all the filenames in an array, you can just move the array item count up one for each next item, that's an easy way to do it, that's how I do my galleries. That way it doesn't matter what the file name is., like gallery.php?image=4 will call image 0 of the array, the links will go to image 3 and 5 in the array. The query string determines what the array count is, what image appears, and what links are written.

LangDesigns

4:24 pm on May 24, 2004 (gmt 0)

10+ Year Member



If you had every image recorded in a flat file or database you can do exactly your +1 or -1 query.
page.php?number=1
----

$query = "SELECT * FROM table WHERE image = '".$number."'";

$query = mysql_query($query);

While ( $img = MySQL_fetch_array($query) ) {
$url = $img['img_url']; // this is where the image is located(the URL)
$number = $number + 1; //adds 1 so you can find the next picture

echo "<img src=\"{$img}\">";

echo "<a href=\"image.php?number=$number\">NEXT</a>";
}

This will inturn, go to page.php?number=2 and will get image 2