Jeg har lavet nogle skrivefejl i SQL'en, så prøve med følgende:
- <?php
-
- $photoID = $_GET['photosID'];
- $categoryID = $_GET['category'];
-
- $gallery = mysql_query("SELECT
- photos.photoID AS photoID,
- photos.photo_date AS photoDATE,
- photos.photo AS photo,
- photos.description AS photoDesc
- FROM photos
- WHERE photos.photosID = '{$photoID}';
-
- IF EXISTS(SELECT photosID as NextID FROM photos WHERE fk_category_id = '$categoryID' AND WHERE NextID > '$photoID' ORDER BY NextID ASC LIMIT 1)
- THEN SELECT photosID as NextID FROM photos WHERE fk_category_id = '$categoryID' AND WHERE NextID > '$photoID' ORDER BY NextID ASC LIMIT 1;
- ELSE
- SELECT photosID as NextID FROM photos WHERE fk_category_id = '$categoryID' AND WHERE NextID > 0 ORDER BY NextID ASC LIMIT 1;
- END IF;
-
- IF EXISTS(SELECT photosID as prevID FROM photos WHERE fk_category_id = '$categoryID' AND WHERE prevID < '$photoID' ORDER BY prevID ASC LIMIT 1)
- THEN SELECT photosID as prevID FROM photos WHERE fk_category_id = '$categoryID' AND WHERE prevID < '$photoID' ORDER BY prevID ASC LIMIT 1;
- ELSE
- SELECT photosID as prevID FROM photos WHERE fk_category_id = '$categoryID' ORDER BY prevID DESC LIMIT 1;
- END IF;
- ");
-
- while($gallery_row = mysql_fetch_assoc($gallery))
- {
- $t = strtotime($gallery_row['photoDATE']);
- $dato = date("j/n-Y H:i", $t);
-
- print '
- <img style="border:0px" width="600" height="400" src="photos/'.$gallery_row['photo'].'"></img>
-
- <div id="description_photo">
- <span class="view_dates">
- -Uploadet den. '.$dato.'-
- </span>
- <br />
- <br />
- '.$gallery_row['description'].'
- </div>
- <br />
- <br />
- <span class="read_comment">
- <a href="photo.php?photosID='.$gallery_row['photosID'].'">Kommentar</a>
- </span>
- <span class="prev_image">
- <a href="photo.php?photosID='.$gallery_row['prevID'].'">Forrige</a>
- </span>
- <span class="next_image">
- <a href="photo.php?photosID='.$gallery_row['NextID'].'">Næste</a>
- </span>
- ';
- }
-
- ?>