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

MASS PM
Hello all, I'm trying to send mass private messages to users in my database but keep getting an erro

Is there a way to override built in php functions without APD?
I am trying to use the
rename_function()
override_function()
options that are built into

Sequre login with cookies.
I want to build secure login with cookies. I just want your ideas about this, your suggestions. What

How to use Ajax to verify data on a DB ?
Hello everyone, well i want to know how to check a value if it exists or not on a Data base and capt

Parse XML
Good day,

I use oempro software and try to parse XMLReturn but it's not working for me, simpl

temporary objects
Until now i thought every temporary object in C++ is created as constant. I'm wondering why my compi

phph within href not showing php if change ? to &
Code: [Select]<a href="<?php echo $puser; ?>?m=<?php=(($m-1)&l

Probably Easy, Need help with Check Boxes in PHP Code
hello,

Thanks for looking this over and helping me out. My problem is I have a online store l

PECL uploadprogress for php5.2
Hey, I just installed PHP5 via .htaccess on my 1and1 Shared Hosting Account.

How would I exac

that old Malformed Headers problem again!!!!! HELP!!!!!!
I've read the http://www.phpfreaks.com/forums/index.php/topic,37442.0.html

I don't think my c

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