Jump to content


Photo

Image slideshow woes...


  • Please log in to reply
1 reply to this topic

#1 ching-a-ling

ching-a-ling
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 30 May 2006 - 02:46 AM

Hello everybody!

Ok, here is my problem. I want to make a slideshow sort of page, where a user clicks on a thumbnail from a photo gallery and a window pops up that shows the image and "next" and "previous" buttons. I am having so much trouble with this! The image data is stored in a database, and the problem is that I can't figure out how to load the two images that are nearby the current image. The code I have so far is below. Thank you so much!



    $current_pic = mysql_query("SELECT image_path FROM pictures WHERE id = '$id'");
    $pix = mysql_query("SELECT id FROM pictures WHERE category1 = '$cat' OR category2 = '$cat' OR category3 = '$cat' AND id != '$id'");
    $img = mysql_result($current_pic, 0);
    $next = mysql_result($pix, 0);
?>


<? if($prev){ echo "<a href=\"$PHP_SELF?id=$prev&cat=$cat \"><img src=\"previous.gif\" border=\"0\"></a>"; } ?>
<a href="<? echo "$PHP_SELF?id=$next&prev=$id&cat=$cat"; ?>"><img src="next.gif" border="0"></a>
</div>

</body>
</html>


#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 30 May 2006 - 05:03 AM

Try to :

1. Modify AND id != '$id'"); to AND id < '$id' LIMIT 1") for previous.
2. Same thing for next, but use id > '$id'

~ D Kuang




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users