View Full Version : blob image problem

05-11-2008, 02:10 PM
ok ive been trawling through so many tutorials and just cant seem to get this to work. i want to be able to display a blob jpeg file in a table on a html page.


<title>The Bassment: Photo Gallery</title>

<BODY bgcolor="#006699">
$db_host = 'localhost';
$db_user = '*****';
$db_pwd = '*****';

$database = 'jenkem_flash';
$table = 'ae_gallery';

if (!mysql_connect($db_host, $db_user, $db_pwd))
die("Can't connect to database");

if (!mysql_select_db($database))
die("Can't select database");

// sending query
$result = mysql_query("SELECT * FROM {$table} order by id");
if (!$result) {
die("Query to show fields from table failed");

$fields_num = mysql_num_fields($result);

echo "<h1>Photo Gallery</h1>";
echo "<table border='2'><tr>";
// printing table headers
for($i=0; $i<$fields_num; $i++)
$field = mysql_fetch_field($result);
echo "<td><b>{$field->name}</b></td>";
echo "</tr>\n";
// printing table rows
while($row = mysql_fetch_row($result))
echo "<tr>";

// $row is array... foreach( .. ) puts every element
// of $row to $cell variable
foreach($row as $cell)
echo "<td>$cell</td>";

echo "</tr>\n";

This code outputs a html table with all the field headings and information, however for the actual blob file all that comes out is a bunch of jargonned syntax. any help would be so much appreciated

05-11-2008, 02:30 PM
You probably need to start by learning the HTML necessary to place an image on a web page - http://www.w3schools.com/html/html_images.asp

You cannot output image data directly on a web page. You need to use an <img src="url_to_image"...> tag for each image. The browser then fetches each image through the url in the src="..." parameter.

05-12-2008, 02:13 PM
HTML is HTML, images are images. Those images need to be separate files. Technically, there is a way for them to be in the same document, but that is not likely to be what you are looking for.