Displaying image from database


Posted on 16th Feb 2014 07:03 pm by admin

Hi,

I've got a site where that's got a database behind it. Currently it has loads of items in rows that all have different pictures. There is a field called "Image" that has the name of the image ie. example.jpg.

Then I have a folder on my webserver called image where the pictures are stored with the same file names and extensions.

Now, I want to display the correct image for the item that the page is showing. I have this code but it's just showing the usual box with a red X in the top left.

I should also point out that the 'Item' line is working correctly and displaying the name of the item.

Quote<table border='1' align="left" width="100%">
<?php
while($row = mysql_fetch_array( $result )) {
$dir = '/image';
$image = $row['Image'];
echo('<b><h1>'.$row['Item'].'</h1></b><br />');

echo "<tr>";
echo "<td width=15%>"."<img width=100% src='$dir/$image /'></td>";
echo "<td width=85% align=center>Description</td>";
echo "</tr>";
}
?>
</table>
Any ideas why this isn't working?

No comments posted yet

Your Answer:

Login to answer
104 Like 35 Dislike
Previous forums Next forums
Other forums

IIS on 2003 anon access disabled issue
I have an IIS server that belongs to a domain, and anonymous access is turned off for all my sites.

storing video files into mysql in php
hi

i have my video files in my folder ,
i have to store the path of the videos into db an

Timer control causing error
I recently decided to add a timer control to an existing page that uses AJAX on my site. As soon as

Error In Syntax
I got this error:

Code: Parse error: syntax error, unexpected '>' in /home/bucket/publ

MySQL-PHP Query Results Help
Hello all. I'm hoping to be able to get some help in solving a problem with query/rowcount output. I

mysql select with $_get ?
Hi, i have this code:
Code: // If char id is 0 and character dont exist do:
if ($_GET["id

How to convert this array to string
I am having problems converting this array to a string
using print_r($val[1]); I get:
Code: [

Consuming third party Payment Gateway API from Procedure.
Hi All,

First of all i would like to thank all the people of the oracle forum for providi

Simpler method of getting variables from mysql
Hi Guys,

I'm trying to streamline my CMS's code and as I was writing a new page it occured to

Embedding flash object in Else statement
This is my first major project in PHP and I'm having some trouble embedding a flash object in an Els

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash