include '../db/config.php';
include '../db/opendb.php';
$photo=$_GET['pic']; //passed from view-album for album id clicked on
$the_album=$_GET['album'];
mysql_select_db($database) or die('Error, could not select the database');
$query="SELECT * FROM fc_pics WHERE id=$photo ORDER BY id DESC";
$result=mysql_query($query);
if (!$result)
{echo("
Error accessing database " . mysql_error() . "
"); include
'closedb.php'; exit(); }
$num=mysql_num_rows($result);
$i=0;
while ($i < $num)
{
$id=mysql_result($result,$i,"id");
$desc=mysql_result($result,$i,"desc");
$author=mysql_result($result,$i,"author");
$file=mysql_result($result,$i,"file");
$thumb=mysql_result($result,$i,"thumb");
$size=mysql_result($result,$i,"size");
$views=mysql_result($result,$i,"views");
$cdate=mysql_result($result,$i,"created_date");
$adate=mysql_result($result,$i,"access_date");
$main_pic="
\n Posted by: $author
\n Description: $desc
\n
Size: $size bytes
\n
Posted on: $cdate\n
Back to album home\n";
$main_id=$id;
$i++;
}
/////////////////////////////////////////////////////////////////////
// get image before and after this one and show thumbnails of them,
// display to the left and right of this center image
$before=$photo-1;
$after=$photo+1;
$query="SELECT * FROM fc_pics WHERE id in ($before,$after) AND in_album=$the_album ORDER BY id DESC";
$result=mysql_query($query);
if (!$result)
{echo("Error accessing database " . mysql_error() . "
"); include
'closedb.php'; exit(); }
$num=mysql_num_rows($result);
$i=0;
print "\n";
$pre_pic="";
$post_pic="";
while ($i < $num)
{
$id=mysql_result($result,$i,"id");
$thumb=mysql_result($result,$i,"thumb");
if ($id<$main_id){$post_pic="
Next";}
if ($id>$main_id){$pre_pic="
Previous";}
$i++;
}
// later add update to database logging this view and new access date
//////////// DISPLAY IMAGES
print "$pre_pic | $main_pic | $post_pic |
";
include 'closedb.php';
?>