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,Im ageSX($im),ImageSY($im));
ImagejpeG($thumb);
imagedestroy ($im);
imagedestroy ($thumb);
mysql_close ($link);
}
?>
It is only displaying one image.
Thanks
M. 3 4719
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,Im ageSX($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.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attglobal.net
==================
Not sure on how to do that as I am new to PHP.
m.
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:u8******************************@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,I mageSX($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.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attglobal.net
==================
Michael Martin wrote:
Not sure on how to do that as I am new to PHP.
m.
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:u8******************************@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. js*******@attglobal.net
================== This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Peter Bach |
last post by:
Would a medium sized (~500 pages) database driven website, search
engine and mailing list be too much for one MySQL database? Instead of
making using different databases I would use different...
|
by: JakeC |
last post by:
Hey all,
I'm currently redesigning a website that a friend and I started about a year
ago. It is a daily surf report so when choosing the best script/language to
use for the new design, I found...
|
by: Jim S. |
last post by:
Hi guys,
i have lots of data for products (with different categories) and pictures
that i would need it entered into a database on the website. How would i go
about doing so?
i was thinking...
|
by: Ray in HK |
last post by:
Will it be possible to specify the date format of type DATE during data
loading ?
|
by: Wadim Grasza |
last post by:
I want to store and display (on a form or a report) multiple pictures
per
record in an access database. The pictures are not stored within the
database. They are stored as files and the database...
|
by: nsh |
last post by:
mailing.database.mysql, comp.lang.php
subject: does "LOAD DATA" EVER work?!? I've tried EVERYTHING!
version info:
my isp is running my web page on a linux box with php ver. 4.4.1
according to...
|
by: C.Joseph Drayton |
last post by:
Hi All,
I have a web site I am developing, and have a question. I would like
members to be able to upload pictures.
Do you think they should be saved as individual files or should they be
put...
|
by: Anthony Smith |
last post by:
Can someone point me to a resource or something were I can set this up
cleanly. I don't want to re-invest the wheel. I just want the most
common way to do this. I know there is a database option...
|
by: Markus |
last post by:
What i want to do:
Get urls from the database and echo them out into a multiple columned table i.e. 4 pictures per row (recently uploaded table)
MY problem is:
I have, in my MySQL database,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |