Page 1 of 1

image doesnt appear within <table></table> ?

Posted: Mon Apr 20, 2009 9:44 pm
by azhan
hey guys,

recently i wanted to retrieve image inside a table but the image doesnt appear at all, but when i run the code in another page without the table clause....it works! hurmm....how do i retrieve an image INSIDE <table></table> ???
below is my code of retrieving image...

Code: Select all

<?php 
// Connects to your Database 
mysql_connect("localhost", "username", "password") or die(mysql_error()); 
mysql_select_db("hospital") or die(mysql_error()); 
 
$rs = mysql_query("select * from pix where title='apple'");
$row = mysql_fetch_assoc($rs);
$imagebytes = $row[imgdata];
header("Content-type: image/jpeg");
print $imagebytes;
 
?>
this code works perfectly...but it doesnt have table....could anyone suggest how to include this INSIDE a table...i've tried echo "<table>"..but still doesnt work....

please please help me...

thanks
Azhan

Re: image doesnt appear within <table></table> ?

Posted: Mon Apr 20, 2009 10:00 pm
by Christopher
That script is an image. It returns the header and byte stream of an image. You would put the code above in a script named something like image_apple.php and then reference that script in the <img> tag like this:

Code: Select all

<table>
<tr>
<td><img src="image_apple.php"/></td>
</tr>
</table>