Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML HTML Basics

<img src=...> but with variable

Discussing Html . Code , Software , other

Moderators: macek, egami, gesf

<img src=...> but with variable

Postby iwakteri » Thu Dec 23, 2010 12:05 pm

Hi..

I want to display an image with <img src=...> tag. But the URL of the image is in a variable.
$picadress="http://........";

And I want to do something like this
<img alt="" src=$picadress />

But unfortunately... it fails :( I already add ' or "... but still fail :(

Is it possible to display the image ? Or is there any workaround to do this?
Thank you very much.
iwakteri
New php-forum User
New php-forum User
 
Posts: 1
Joined: Thu Dec 23, 2010 11:57 am

Re: <img src=...> but with variable

Postby lokanath7 » Fri Dec 24, 2010 12:09 am

do this
<img alt="" src="<?php echo $picadress;?>" />
lokanath7
New php-forum User
New php-forum User
 
Posts: 139
Joined: Mon Nov 15, 2010 12:11 am

Re: <img src=...> but with variable

Postby mayhemiz » Wed Jan 19, 2011 8:02 am

hello,or simply:

Code: Select all
<?php
echo "<img src=\"".$variable."\">";
?>
mayhemiz
New php-forum User
New php-forum User
 
Posts: 38
Joined: Thu Dec 09, 2010 8:13 am

Re: <img src=...> but with variable

Postby Ali » Tue Feb 01, 2011 3:15 am

suppose the image coming from http://domain.com/images/img1.jpg
you can do it with like this
<img src="<?=$path?>"/> //where $path=images/img1.jpg
dont need to look whole path bcoz u,r file would be in root directory.
indianssoftwarecomapny.com
Ali
New php-forum User
New php-forum User
 
Posts: 3
Joined: Tue Feb 01, 2011 2:40 am

Re: <img src=...> but with variable

Postby zeneth » Fri Jun 24, 2011 10:54 pm

Thanks for suggesting.
Actually I'm working on a project and I'm also facing the same problem.
Thanks once again :)
zeneth
New php-forum User
New php-forum User
 
Posts: 1
Joined: Fri Jun 24, 2011 10:38 pm


Return to HTML Basics

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.