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.

Did you know?Explore Trending and Topic pages for more stories like this.
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

Save User Inputs while javascript reloading!
hi..
i have written a PHP code in which i reload the page when user selects a value in dropdown..

mysql_query returning boolean instead of mysql ressource
Hi,

I seem to have a weird issue with the php command mysql_query. I pass 2 arguments the que

Confusing Functions
So, I've been reading up on Functions and I like them! However, I need some help using variables in

ASP.NET 2.0 - Enter Key - Default Submit Button
Hi,One of the most annoying things in developing web pages is handling the "Enter key" for form subm

Disabling SAP menu
How do I disable SAP menu for all the users and just restrict them to User Menu in SAP ECC 6.0?

Post, not working, please help
The error is:
Method Not Allowed
The requested method POST is not allowed for the URL /student

Check Date/Time in PHP
What I need the code to check is that $reQuest is 24 hours in the past then return a time based on h

login page does not execute a else statement
I've created a login page using sessions.
When an incorrect user name or password is entered then

SAP Business Suite
Hi all:

Within the SAP Business Suite solution I would like to ask you the main differenc

foreach and array need help combining
Hi guys.

Here's the code

Code: array(
'tag' => 'code',<

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