You can't do what you're trying to do because you're trying to echo out binary data on a web page.
Images are seperate things, and seperate requests are made by the browser to get those images.
Instead, you should echo the filepath to the image:
<img src="/path/to/php/file_which_makes_a_query_sends_a_header_and_outputs_image.php?getImageFromDB=imageFromDB.jpg">
And then this file:
path/to/php/file_which_makes_a_query_sends_a_header_and_outputs_image.php
Would make a query for $_GET['getImageFromDB'], send a header("Content-type: image/jpeg"); ( or PNG/GIF/etc. ) and then print the binary data.
I should note that the MySQL manual specifically reccomends AGAINST storing images in a database because of performance reasons.