How do I display an image?

From: "Patrick Hatcher" <PHatcher(at)macys(dot)com>
To: pgsql-php(at)postgresql(dot)org
Subject: How do I display an image?
Date: 2002-10-24 00:04:21
Message-ID: OF89E4C36B.5033CB75-ON88256C5B.0083CDB2-88256C5C.00006310@fds.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

Fairly new to PHP. How do I display an image I have stored in my db? I
found code on phpbuilder.com, but I must be doing something wrong. If I
just print out the field, it prints the machine code immediately. But I
alas my users want an image instead of machine language.

CREATE TABLE mdc_imageref (
keyp_imageref int4,
modid int8,
img bytea,
keyf_image int4
)

$id = $_GET["id"];
if($id) {
$db = db_connect();
$result = pg_query($db,"Select ir.img,p.keyp_products
from mdc_products p join mdc_product_images pi on
p.keyp_products = pi.keyf_product
join mdc_attributes a on a.keyp_attribute =
pi.keyf_attribute
join mdc_images i on i.keyp_images = pi.keyf_image
join mdc_imageref ir on ir.keyf_image = i.keyp_images
where p.keyp_products = $id and keyp_attribute = 7");
$row = pg_fetch_array($result);
$type = "JPG";
Header( "Content-type:$type");
echo $row[0];
}

TIA
Patrick Hatcher
Macys.Com
Legacy Integration Developer

Responses

Browse pgsql-php by date

  From Date Subject
Next Message Cornelia Boenigk 2002-10-24 00:36:35 Re: How do I display an image?
Previous Message Maxim Maletsky 2002-10-22 13:02:15 Re: search/select case-insensitivly.