Pictures in DB

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ansa1
Forum Newbie
Posts: 16
Joined: Sat Mar 27, 2004 9:19 am
Location: Ontario, Canada

Pictures in DB

Post by ansa1 »

Hi,
I created a page that displays information about some applications (models). Everything works perfect, with a small exception. I need to display its picture as well. They are stored in a DataBase. I tried a reference of $_GET . REQUEST …. I can’t get it to work . I am more a designer than a programmer however I started in PHP MYSQL ………… LOL.
I am using the following code:

Code: Select all

<?php
 $sql2="SELECT * FROM image INNER JOIN model WHERE model.ID=image.id AND image.id ='".$_GET['id']."'";
$result = mysql_query($sql2) OR DIE (mysql_error());
if (mysql_num_rows($result)>0){
$row = @mysql_fetch_array ($result);
$image_type = $row["image_type"];
$image = $row["image"];
Header ("Content-type: $image_type");
print $image;
}
mysql_close();


?>

they work fine for :

Code: Select all

&lt;img src="application_group.php?id=3"&gt;
for picture # 3.
But I need it to display by models id (id) . Can somebody provide me with right answer please .

Thanks ....
User avatar
potsed
Forum Commoner
Posts: 50
Joined: Sat Oct 09, 2004 12:00 pm
Location: - South Africa

Post by potsed »

not sure waht your getting at ... if
they work fine for :

Code: Select all

<img src="application_group.php?id=3">
for picture # 3.
what exactly is wrong...
ansa1
Forum Newbie
Posts: 16
Joined: Sat Mar 27, 2004 9:19 am
Location: Ontario, Canada

Post by ansa1 »

Hi ,
<img src="application_group.php?id= 1, 2, 3, 4, …….."> this is for testing purpose.

I want to call tem dynamically. By model id. If you click a link, and enter a page with particular model information, all information about this model are called from DB, by model ID. I can’t figure out, what script should call the picture from DB. I believe something like this :

Code: Select all

<?php echo "<img rc="application_group.php?id=&#123;$row&#1111;"id"]&#125;">";?>
But it’s not working.
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

why are you putting {} around $row['id'] ?
you also can't put arrays into your code like you have done.
you have to

Code: Select all

<?php
echo "<input type="button" name="someName" id="someId" value="".$row['id']."" />";

?>
Post Reply