Reply to Re: Load multiple pictures into MySQL?

Your name:

Reply:


Posted by Jerry Stuckle on 07/25/06 10:48

Michael Martin wrote:
> Not sure on how to do that as I am new to PHP.
>
> m.
>
> "Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
> news:u8KdnWjRYouC4VjZnZ2dnUVZ_rSdnZ2d@comcast.com...
>
>>Michael martin wrote:
>>
>>>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.
>>>
>>><?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);
>>> }
>>>?>
>>>
>>>It is only displaying one image.
>>>
>>>Thanks
>>>M.
>>
>>You can't do it this way. The content-type header indicates a single
>>image will be generated.
>>
>>You can split this into 2 files - the first one gets the rows and calls
>>the second once for each row to display the jpeg.
>>

The first file contains all the sql code. It gets the data from the
database and generates an <img...> attribute in the HTML. This
attribute as the second file as its src and passes the filename of the
image being displayed to the second file.

The second file does all the work needed to create images. You probably
pulled the code you have out of a similar file. It gets I generates the
content header and all the image stuff itself. It knows which image to
use from the passed parameter.

Does this help with the process? Also, please don't top post.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original 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

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