Page 1 of 1

Pictures in DB

Posted: Sat Nov 20, 2004 8:19 pm
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 ....

Posted: Sun Nov 21, 2004 1:54 am
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...

Posted: Sun Nov 21, 2004 9:03 am
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.

Posted: Mon Nov 22, 2004 3:03 am
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']."" />";

?>