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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
azhan
Forum Commoner
Posts: 68
Joined: Fri Jun 27, 2008 6:05 am

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

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

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

Post 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>
(#10850)
Post Reply