Displaying Image stored on Server

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cdoyle
Forum Contributor
Posts: 102
Joined: Wed Feb 13, 2008 7:26 pm

Displaying Image stored on Server

Post by cdoyle »

Hi,

I'm tried to search the forum, but the search doesn't seem to be working.

I'm new to PHP, and what I'm trying to do is this.

I have a mysql database, that I added a column too. This column holds the URL to an image stored in a directory on the server.

What I would like to do on my PHP page, is display the image when the page is opened.
Here is the section where I want to display the image, I would like it right before the description.

Code: Select all

            while ($item = $query->fetchrow())
            {
                echo "<fieldset>\n";
                echo "<legend><b>" . $item['name'] . "</b></legend>\n";
                echo "<table width=\"100%\">\n";
                echo "<tr><td width=\"85%\">";
                echo $item['description'] . "\n<br />";
                echo "<b>Effectiveness:</b> " . $item['effectiveness'] . "\n";
                echo "</td><td width=\"15%\">";
                echo "<b>Price:</b> " . $item['price'] . "<br />";
                echo "<a href=\"shop.php?act=buy&id=" . $item['id'] . "\">Buy</a><br />";
                echo "</td></tr>\n";
                echo "</table>";
                echo "</fieldset>\n<br />";
The field in my database is called Item_Image
I tried echo $item[Item_Image]; just to verify that it's getting the info from the db, and it outputs the URL fine.

I just can't figure out how to get the image to show on my page when it's open.

Any ideas?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Displaying Image stored on Server

Post by Christopher »

Code: Select all

               echo "<img src=\"" . $item['Item_Image'] . "\"/>";
(#10850)
cdoyle
Forum Contributor
Posts: 102
Joined: Wed Feb 13, 2008 7:26 pm

Re: Displaying Image stored on Server

Post by cdoyle »

Perfect!

Thank You!!!
Post Reply