I'm creating a gallery of pictures. The picture id are not in any order.
What i would like to do is to do a query on the db and that brings back 3 id's, pic1 and pic2. your GID will be set in the URL ex. http://test.com?gid=10
I need to display the one that matches the gid the one before and the one after.
This is the code that i have been using but's isn't working.
$sql = "SELECT id,pic1,pic2 FROM gallery ORDER by id";
$result = mysql_query($sql,$db);
while ($r = mysql_fetch_array($result)) {
extract($r, EXTR_PREFIX_ALL, "IN");
if($IN_id == ($gid-1)) {
$presm = $IN_pic2;
$preid = $IN_id-1; }
if($IN_id == $gid)
$bigpic = $IN_pic1;
if($IN_id == ($gid+1)) {
$postsm = $IN_pic2;
$postid = $IN_id+1; }
}