You are here: Load multiple pictures into MySQL? « PHP SQL « IT news, forums, messages
Load multiple pictures into MySQL?

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.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация