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