Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Oct 2010
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts

    PHP while loop problem

    Hey,

    I have the following code:

    PHP Code:
    while($assoc3 $db->assoc($query3))
    {

    //Displays photos
    echo "<a href='#' class='lightbox'><img src='".$assoc3[img_location]."' width='100' height='100' style='margin:5px' /></a>";

    //Open lightbox (PROBLEM)
    echo "<div class='backdrop'></div><div class='box'><div class='close'>x</div><img src='".$assoc3[img_location]."' width='100' height='100' /></div>";


    which loops though the database and all the thumbnails of pictures in an album. However when I add the code to open a lightbox because its in the loop in the lightbox I get all the pictures instead of just the one I clicked on. How can I make it so that it only displays the picture I clicked on in the lightbox?

    Thanks

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,456
    Thanks
    8
    Thanked 1,084 Times in 1,075 Posts
    Doesn't lightbox have the "image set" feature where you
    have to put something like this for each <a href> tag?
    rel="lightbox[photos]"

    http://lokeshdhakar.com/projects/lightbox2/

    What "lightbox" are you using? JQuery?

  • #3
    New Coder
    Join Date
    Oct 2010
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Yeah I am using jQuery but not the lightbox from the link you have

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,456
    Thanks
    8
    Thanked 1,084 Times in 1,075 Posts
    Give us the link to the script you are using.
    I still think you have missing things that relate to the lightbox javascripting.

  • #5
    New Coder
    Join Date
    Oct 2010
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •