Displaying URLs in database as images

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
phelpsa
Forum Commoner
Posts: 48
Joined: Thu Feb 17, 2005 1:05 pm

Displaying URLs in database as images

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

make the address the "src" of an html image.
phelpsa
Forum Commoner
Posts: 48
Joined: Thu Feb 17, 2005 1:05 pm

Post by phelpsa »

I tried....

Code: Select all

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

Am I doing it right?

Adam
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Have a read through the manual on strings: http://php.net/language.types.string
phelpsa
Forum Commoner
Posts: 48
Joined: Thu Feb 17, 2005 1:05 pm

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Read the difference between double and single quotes on the page which feyd linked :wink:
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post 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
Post Reply