images display noob question

images php coding issues or problems here.

Moderators: macek, egami, gesf

darkapple
New php-forum User
New php-forum User
Posts: 19
Joined: Wed Feb 23, 2011 10:57 am
Location: Essex, United Kingdom

images display noob question

Postby darkapple » Wed Feb 23, 2011 11:06 am

Hi all,

Hope you can help, I am learning php and just need to ask a quick question.

I want to display a image in php, and wondered what the code would be, the image name is a string eg $image="test.jpg" and is in a image directory.

Hope that makes sense

Thanks

User avatar
Nullsig
php-forum Fan User
php-forum Fan User
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Re: images display noob question

Postby Nullsig » Thu Feb 24, 2011 8:31 am

if you have saved the file name of the image all you have to do is echo out the image tag like so:

Code: Select all

echo '<img src="<path to directory>/$image">';

darkapple
New php-forum User
New php-forum User
Posts: 19
Joined: Wed Feb 23, 2011 10:57 am
Location: Essex, United Kingdom

Re: images display noob question

Postby darkapple » Thu Feb 24, 2011 10:32 am

You star, thank you

rfcamat
New php-forum User
New php-forum User
Posts: 4
Joined: Tue Mar 15, 2011 5:25 pm
Location: Brea, California
Contact:

Re: images display noob question

Postby rfcamat » Tue Mar 15, 2011 5:36 pm

Hi how can I make the image clickable? THanks

User avatar
Nullsig
php-forum Fan User
php-forum Fan User
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Re: images display noob question

Postby Nullsig » Tue Mar 15, 2011 5:50 pm

clickable how? You can click on that image it will just do nothing... If you want to tie the image to a link you can just surround it with <a> tags like so:

<a href='somerandomwebsite.com'><img src='test.jpg'></a>

If you want to do something more complex like tie it to a javascript action involving AJAX or client side alteration of the page it is a little more complex and I would rather have an idea where you were trying to get than over generalizing the solution


Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 1 guest