I have the following code to fetch images from an SQL data where a "gallery" id is set and a "artworks" id is set. BTW the "artworks" is really the images which I want to display. I am able to display the first image OK, however the "next" and "before" images don't show up although the URL status does increment the id requested.
I only want one image at a time incremented by a mouse action for "next" and "previous."
//display gallery name for use from the referring page where the gallery is selected
<?php
include("design/header.php");
require("connect.php");
$galleryid = $_GET['gallery'];
$id = $_SESSION['id'];
//display gallery name
$gallery = mysql_query("SELECT gallery_name FROM galleries WHERE id='$galleryid'"); $galleryarray = mysql_fetch_assoc($gallery);
echo "<table width='220' cellpadding='7'> <tr> <td>
<br><br><font size='5' face='verdana' color='#006600'>".$galleryarray['gallery_name']."</font><br>
<font size='2' face='verdana'><a href='managegalleries.php'><b>Return </b></a>to Galleries Admin</font> </td> </tr> </table>";
$image = mysql_query("SELECT * FROM artworks WHERE userid='$id' AND galleryid='$galleryid'"); $folder = mysql_query("SELECT * FROM artworks WHERE userid='$id' AND galleryid='$galleryid'");
if ((mysql_num_rows($image)<=0))
echo "Sorry that gallery doesn't exist!";
while ($row = mysql_fetch_assoc($image)) //currently displays all the images
// $row = mysql_fetch_assoc($image); //returns one image as $p below but no looping
{
//set up integer counting of items in folder but it doesn't fetch a next and previous
$i = intval($row['i']);
$c = 0;
$p = $row['folder']."/".$row['location']; //$p gets the one image returned if not using the while statement
if ($i==$c)
$c++;
if (strlen($p)>0)
{
$i1 = ($i+$c-1); //$i1 decrements OK
$i2 = ($i+$c+1); //$i2 increments OK
print
"<a href=\"player.php?i=$i1\">-</a> "
."<img src=\"$p\" border=\"0\" width=\"$width\" "
."<a href=\"player.php?i=$i2\">+</a><br\>\n";
}
}
?>