Jump to content

Jezw

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Jezw's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. My array search was placed inside $images_in_gallery[]; so basically it's doing $images_in_gallery[5] with 5 being the key and the variable being the value of the key which could be anything. Here's a screenshot showing what i mean, i won't embed it as it's fairly large (337KB PNG): http://img33.imageshack.us/img33/9020/debugging.png Passing the gallery id through in the URL seems like a very good idea i'll build that in, it also gives me a lot more flexibility with the data. I'll look through the guide you linked now it looks a lot more straight forward than any other paging guides i've seen.
  2. Okay so i have an image gallery script that creates two links, "Next Image" and "Previous Image". The script works but i'd like to know if i could make it more efficent with a better SQL query. Here's my database What i am currently doing is querying the database and getting a list of all the image id's in the same gallery, and putting them into an array. Which doesn't seem very logical (but it's the only solution i could come up with). // CREATE AN ARRAY WITH ALL THE IMAGE ID'S IN THE GALLERY // $query = ("SELECT id FROM images WHERE gallery_id=(SELECT gallery_id FROM images WHERE id='".$_REQUEST['id']."') ORDER BY id DESC"); $result = mysql_query($query); $images_in_gallery = array(); while ($row = mysql_fetch_array($result)) { array_push($images_in_gallery, $row['id']); } And then searching through said the array to get the id of the next image and the previous image. // CREATE THE LINK // $next_link = "<a href=\"?id=".$images_in_gallery[array_search($_REQUEST['id'], $images_in_gallery)+1]."\">$next_text</a>"; $prev_link = "<a href=\"?id=".$images_in_gallery[array_search($_REQUEST['id'], $images_in_gallery)-1]."\">$prev_text</a>"; Is there a way i can do this easier with a better query, for example a query that selects the next image in the gallery and the previous, i am not brilliant with SQL but i do know that if you have a good query your code can be considerably shorter. The full code can be found here on pastebin. http://pastebin.com/GzTpq6Uj
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.