Here's a challenge for anyone willing to save me from throwing office supplies at my co-workers.
If you read through my slop of code here, I'm trying to build a photo gallery for the client. I want it to go to the next picture (or previous), but I need to know the photoid (a field from the table) to display the picture. How the heck would you go about this?
Should I use a select with a limit??
Code: Select all
if($function == "View Image")
{
$album = $_GET['album'];
$photoid = $_GET['photoid'];
$o = $_GET['o']; // the number photo it is in the album
$a = $_GET['a']; // the number of photos in the album
echo "<a href=\"?pg=6\">Back to All Albums</a><br>";
echo "<a href=\"?pg=6&function=See Album&album=$album\">Back to $album</a><br><br><center>";
$query = "select * from photos where photoid = '$photoid';";
$result = mysql_query($query);
$fetch = mysql_fetch_array($result);
extract($fetch);
// Previous & Next Photo
echo "<table border=\"0\" width=\"500\"><tr><td width=\"250\">";
// if this is the first photo, there is no previous photo
if($o != 1)
{ $newo = $o - 1;
echo "<a href=\"?pg=6&function=View Image&album=$album&photoid=x&o=$newo&a=$a\">Previous Photo</a>"; }
echo "</td><td width=\"250\" style=\"text-align: right;\">";
// if this is the last photo, there is no next photo
if($o != a)
{ $newo = $o + 1;
echo "<a href=\"?pg=6&function=View Image&album=$album&photoid=x&o=$newo&a=$a\">Next Photo</a>"; }
echo "</td></tr></table>";
echo "<img src=\"scope.php?image=$imgsrc&maxsize=500\" style=\"border: 1px solid #513751;\"><br><span style=\"font-family: arial; color: black;\">
$caption";
}
}Code: Select all
if($o != a)
{
$newo = $o + 1;
echo "( $newo )";
$query = "select * from photos where album = '$album' limit $newo, 1";
$result = mysql_query($query);
$fetch = mysql_fetch_array($result);
extract($fetch);
echo "<a href=\"?pg=6&function=View Image&album=$album&photoid=$photoid&o=$newo&a=$a\">Next Photo</a>"; }
echo "</td></tr></table>";
echo "<img src=\"scope.php?image=$imgsrc&maxsize=500\" style=\"border: 1px solid #513751;\"><br><span style=\"font-family: arial; color: black;\">
$caption";
}
}~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: