Page 1 of 1

Displaying Image stored on Server

Posted: Wed Feb 13, 2008 7:36 pm
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?

Re: Displaying Image stored on Server

Posted: Wed Feb 13, 2008 7:50 pm
by Christopher

Code: Select all

               echo "<img src=\"" . $item['Item_Image'] . "\"/>";

Re: Displaying Image stored on Server

Posted: Wed Feb 13, 2008 7:52 pm
by cdoyle
Perfect!

Thank You!!!