Forum Moderators: coopster

Message Too Old, No Replies

php print a href

         

th1chsn

4:51 pm on Feb 2, 2006 (gmt 0)

10+ Year Member



Does anyone know how to use the print or echo command to display a hyperlink? My code that's giving me an error looks like this:

<?
if ($id == 0) {
print "Not Available";
}
else {
print "<a href="http://www.link.com=$id">$id</a>";
}
?>

TIA for any help.

niels

5:24 pm on Feb 2, 2006 (gmt 0)

10+ Year Member



print "<a href=\"http://www.link.com=$id\">$id</a>";

You need to escape the double quote's within the href

[edited by: niels at 5:27 pm (utc) on Feb. 2, 2006]

mack

5:25 pm on Feb 2, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



niels got it.

You need to use the "\" to prevent php from classing the " as the end of the print or echo.

Mack.

th1chsn

7:44 pm on Feb 2, 2006 (gmt 0)

10+ Year Member



It's amazing what two little \ will do :)

Thanks for the help!