|
Posted by Michael martin on 07/25/06 01:21
I'm trying to create a picture database for a site that I'm working on and I
would like to do the following:
- (main goal) Have a php script load an entire directory of photos into my
mysql database in one swoop.
- Display thumbnails on a general viewing page.
- allow for viewing individual pictures by clicking on the thumbnails
Got something like this;
<?php
error_reporting(E_ALL);
$id = $_REQUEST["iid"];
$link = mysql_connect("localhost", "root", "") or die("Could not connect:
" . mysql_error());
mysql_select_db("mysql") or die(mysql_error());
$sql = "SELECT b1 FROM t1 where id in (1,2,3)";
$result = mysql_query("$sql") or die("Invalid query: " . mysql_error());
header("Content-type: image/jpeg");
while ($row = mysql_fetch_array($result))
{
$fileContent = $row['b1'];
$im = imagecreatefromstring($fileContent);
$width = imagesx($im);
$height = imagesy($im);
$imgw = 50;
$imgh = $height / $width * $imgw;
$thumb = ImageCreate($imgw,$imgh);
ImageCopyResized($thumb,$im,0,0,0,0,$imgw,$imgh,ImageSX($im),ImageSY($im));
ImagejpeG($thumb);
imagedestroy ($im);
imagedestroy ($thumb);
mysql_close ($link);
}
?>
But only displaying one image.
Thanks
m.
[Back to original message]
|