View unanswered posts | View active topics It is currently Sun Oct 02, 2022 2:48 pm

Reply to topic  [ 2 posts ] 
 Insert image code from database 
Author Message
Junior Member

Joined: Sun Sep 28, 2003 1:40 pm
Posts: 1
I can "echo" text from a database onto a web page but I am having problems "echo"ing an image to a web page along with text. Can someone tell me the codeing that would do that?



Sun Sep 28, 2003 1:43 pm
Report this post
Junior Member

Joined: Sat May 10, 2003 1:39 pm
Posts: 37
I remember seeing a an article somewhere on this but can't find it now. From memory :-

The principle is to create a php script in a separate file, which echoes the image, and place the image with an img tag.

:: myimage.php ::

$id = $_GET['id'];
$sql = "SELECT theimage FROM thetable WHERE id=$id";
$res = mysql_query($sql);
list($image) = mysql_fetch_row($res);

header("Content-Type: image/jpg");
echo $image;

:: mypage.php ::

<img src="myimage.php?id=1" >


Hope I got it right


Mon Sep 29, 2003 1:10 pm
Report this post
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 0 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
© Copyright 2003-2008 The ultimate PHP Editor and PHP IDE site.