Re: [Phplib-users] Templates and binary data in mySQL
Brought to you by:
nhruby,
richardarcher
|
From: Richard A. <rh...@ju...> - 2002-04-08 23:18:17
|
At 3:06 PM -0700 8/4/02, Michael Robbins wrote:
>Currently my templates contain lines like: img src="{IMAGE_PATH}"
>
>And this works fine until I don't have a path, but binary mysql data.
You write a little php script which pulls the data from the database
and blats it out as an image. Then point your img src tag to that
script.
e.g.
This script is called as image.php?id=8476
<?php
include("prepend.php3");
$db = new my_DB;
if (!isset($id)) {
$id = 0;
}
$id = intval($id);
Header("Content-type: image/jpeg");
$db->query("select * from products where id=$id");
while ($db->next_record()) {
echo base64_decode($db->f("photo"));
}
$db->free();
?>
...R.
|