Page 1 of 1

Displaying URLs in database as images

Posted: Sun Apr 02, 2006 5:36 pm
by phelpsa
I'll explain as best I can.

I have got a database which stores the address of an uploaded image and the name. The data type of both is text.

I want to display the image, and the code gives me a variable like.....

Code: Select all

$result["address"]
This will give me.....
gallery/bike1.JPG
.....and will display (as text) if I use the code....

Code: Select all

{
echo $result["address"] . " <br>";
echo $result["name"] . " <br><br>----------------<br><br>";
}
How, using this, can i display the image?

Hope you lot can help.

Adam

Posted: Sun Apr 02, 2006 5:44 pm
by feyd
make the address the "src" of an html image.

Posted: Sun Apr 02, 2006 5:57 pm
by phelpsa
I tried....

Code: Select all

echo '<img src="$result["address"]">'
...but it doesn't work.

Am I doing it right?

Adam

Posted: Sun Apr 02, 2006 5:59 pm
by feyd
Have a read through the manual on strings: http://php.net/language.types.string

Posted: Sun Apr 02, 2006 6:10 pm
by phelpsa
I have read it but I still don't understand :(

Are there any other ways of taking the URL from the database and displaying the image?

Adam

Posted: Sun Apr 02, 2006 6:25 pm
by John Cartwright
Read the difference between double and single quotes on the page which feyd linked :wink:

Posted: Sun Apr 02, 2006 6:31 pm
by Ambush Commander
Some code that demonstrates the difference:

Code: Select all

$hash["key"] = 'value';
echo '$hash["key"]' . '<br />'; //single quotes
echo "$hash['key']"; //double quotes