Page 1 of 1

MySQL Image Gallery

Posted: Wed Oct 21, 2009 1:20 pm
by Bjeffries111
I am trying to great a MySQL image gallery. I am currently working on getting the thumb nails to show up then i want to work on how to link it to a new page.. So far the code that I am suing is not working, I just want to thumbnails to show up with the gallery title and photographer.

Code: Select all

 
<?php
 
$con = mysql_connect("host","dbname","pass");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
 
mysql_select_db("dbnamer", $con);
 
$result = mysql_query("SELECT * FROM photo_albums");
 
echo '<div class="photoThumb">';
 
while($row = mysql_fetch_array($result))
  {
  //echo "<tr>";
  echo '<img src="' . $row['filepath'] . . $row['filename'] . '"';
  echo 'border="0" />"';
  echo '<br/>';
  echo '<span class="thumbText">' . $row['stitle'] . \n . $row['photog'] . '</span>';
  }
echo "</div>";
 
mysql_close($con);
?>
 
Any suggestions?
Thanks,
Brian

Re: MySQL Image Gallery

Posted: Wed Oct 21, 2009 5:08 pm
by Bjeffries111
ok I got this to work with this code:

Code: Select all

 
 
<?php
 
$con = mysql_connect("","","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
 
mysql_select_db("", $con);
 
$result = mysql_query("SELECT * FROM photo_albums ORDER BY uptime DESC);
 
while($row = mysql_fetch_array($result))
  {
  echo '<div class="photoThumb">';
  echo '<img src="' . $row['filepath'];
  echo $row['filename'] . '"';
  echo 'border="0" />';
  echo '<br/>';
  echo '<span class="thumbText">' . $row['stitle'];
  echo  '<br/>';
  echo $row['photog'];
  echo '</span>';
  echo "</div>";
  }
mysql_close($con);
?>
 
there is still one things I want to learn:
1. Where do I start on creating a link out of the thumbnails and going to a new page with all the images?

Thanks,
Brian