We help IT Professionals succeed at work.
Get Started

Output a database stored image

Neil_Bradley asked
Last Modified: 2013-12-12
I have a MySQL table which receives uploaded images.
 id  (int)
title  (varchar)
ext  (varchar)
image_time  (timestamp)
data  (blob)
The upload process works fine however I am having some trouble showing these images. The code snippet shows where I am. Where I would like to be is to have my query show the uploaded images.

(!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database");	
if (!mysql_select_db($database))    
	die("Can't select database");
	?><h1>My image gallery</h1>
<h2>Uploaded images:</h2>
<form action="<?=$PHP_SELF?>" method="post">

<?php $result = mysql_query("SELECT id, title, ext, data, blob, FROM {$table} ORDER BY id DESC");if (mysql_num_rows($result) == 0) // table is empty    
echo '<ul><li>No images loaded</li></ul>';else{    

echo // output my pics   ???

Open in new window

Watch Question
This problem has been solved!
Unlock 2 Answers and 4 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE