MySQL PHP and BlOB Inages

Discuss all aspects of programming here.

Moderator: The Mod Squad

MySQL PHP and BlOB Inages

Postby chrisostomos » Wed Dec 21, 2005 3:38 am

Hi,

I am have made a scipt that uploads images to a MySQL database with blob data type from PHP.
Now i am just wondering how i can retrieve the images and display them. I have managed to display One image, but when i try to display multiple images it just doesnt seem to work, and that where i have been stuck for a while now.

Here is the code...
[php]
<?php
$modelName = "kathy";

$hostname = "localhost";
$username = "root";
$password = "";
$databaseName = "newwavemodels";

// Connect to database
$errmsg = "";
if (! mysql_connect($hostname,$username,$password))
{
$errmsg = "Cannot connect to database";
}

mysql_select_db($databaseName);

$result = mysql_query("select imgdata from pix");

$index = 0;
while($row = mysql_fetch_array($result))
{
header("Content-type: image/jpeg");
echo mysql_result($result, $index);
$index++;
}
?>
[/php]

My table structure is the following:
CREATE TABLE `pix` (
`pid` varchar(11) default NULL,
`title` varchar(10) NOT NULL default '',
`imgdata` longblob,
`thumbImage` longblob,
PRIMARY KEY (`title`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Thanks for any input

Chris Vicatou
chrisostomos
Initiate
Initiate
 
Posts: 79
Joined: Fri Jan 23, 2004 11:13 pm

Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests