Ok. This is a bit of a tricky one to explain. But here goes.
I've created a simple album image viewer http://www.acumendesign.co.uk/rp_cor...test_album.php
Each click of the arrow performs a php request( via ajax ) to retreive the new image.
What I want to do is if the user clicking the right arrow clicks it again after the last image of the album it just loops to the first image. Or if clicking the left arrow it will loop round to select the last image of the album and flow backwards.
I tried to use the code in the php below. I basically selects the next row with $image(which is a number) in the table and returns the result $row['filename'];
If i have 5 images in my album but then the request that comes through is 'select the 6th image' which doesn't exist, what is the result that is returned and how can I translate that into my php query so that I can tell it to perform a new query?
My Javascript is okPHP Code:if(isset($_GET['getimage'])){
$image = $_GET['getimage'];
include "modules/db.php";
$result = mysql_query("SELECT * FROM images LIMIT $image, 1");
}
if($result == " "){
$newresult = mysql_query("SELECT * FROM images LIMIT 0, 1") or die ("Query Error: " . mysql_error () );
while($newrow = mysql_fetch_array($newresult)){
echo $newrow['filename'];
}
}
while($row = mysql_fetch_array($result)){
echo $row['filename'];
}
Thanks







Bookmarks