View unanswered posts | View active topics It is currently Mon Oct 03, 2022 2:45 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
Post 
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?

Thanks

:(


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

Joined: Sat May 10, 2003 1:39 pm
Posts: 37
Post 
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 ::

Code:
$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 ::
Code:
<html>
<body>

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

</body>
</html>


Hope I got it right

_________________
Barand


Mon Sep 29, 2003 1:10 pm
Report this post
Profile
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:  
cron
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.