Page 1 of 1

[SOLVED] href and image source

Posted: Mon Apr 04, 2005 7:19 pm
by chris100
I'm new to php and am trying to duplicate some html code in php.

This is an example of code that I have that works.

echo "<a href = \"$url\">\"aloe.jpg\"</a>\n";

I can create the $url from mysql data but I haven't been able to figure out how to create an <img src of "aloe.jpg". Insted the word "aloe.jpg" appears when I run the script.

I checked the php manual and and googled just about phrase I could think might get some results. No luck!

Any help would be very appreciated.

Thanks

Posted: Mon Apr 04, 2005 7:24 pm
by John Cartwright

Code: Select all

echo '<a href = "'.$url.'">'.$picname.'</a>\n';
or

Code: Select all

echo "<a href = \"$url\">$picname</a>\n";
That what you wanted?

Posted: Mon Apr 04, 2005 7:25 pm
by infolock
chris100 wrote: I can create the $url from mysql data but I haven't been able to figure out how to create an <img src of "aloe.jpg". Insted the word "aloe.jpg" appears when I run the script.

Thanks
that's because you are simply echoing out the image name itself instead of actually showing the image....

Code: Select all

echo "<a href = "$url">"aloe.jpg"</a>\n";
should actually be

Code: Select all

echo '<a href="'.$url.'"><img src="aloe.jpg"></a><br>';

*curses php tag*

Code: Select all

echo '<img src="'.$url.'aloe.jpg"></a><br>';

Posted: Mon Apr 04, 2005 7:26 pm
by feyd

Code: Select all

echo '<a href="' . $url . '"><img src="' . $pic . '" /></a>' . "\n";
:?:

Posted: Mon Apr 04, 2005 7:47 pm
by chris100
Thanks so much guys, it works great. I'll keep on coding and will probably be back with more questions soon.

Thanks again

Posted: Mon Apr 04, 2005 7:50 pm
by John Cartwright
chris100 wrote: will probably be back with more questions soon.
I can't wait ;)