Jump to content

Recommended Posts

When I run this, the hyperlink comes out in text. How do I make the hyperlink come out live?

 

<?php>

 

$pc = $_POST['pc'];

 

If ($pc == 0) {

$pcText = "http://www.yahoo.com";

}

 

else if ($pc == 1) {

$pcText = "http://www.google.com";

}

 

?>

 

<p>Website: <?php echo $pcText ?> </p>

Edited by Pikachu2000
Removed link to competing forum.
Link to comment
https://forums.phpfreaks.com/topic/268834-how-to-echo-hyperlinks/
Share on other sites

This should be in the PHP section, not HTML. but just edit your code a little....

 

<?php
$pc = $_POST['pc'];
If ($pc == 0) {
$pcText = "<a href=\http://www.yahoo.com\">SomeText</a>";
}
else if ($pc == 1) {
$pcText = "<a href=\"http://www.google.com\">SomeText</a>";
}
?>

<p>Website: <?php echo $pcText ?> </p>   

  • 2 weeks later...

<?php>

$pc = $_POST['pc'];

]If ($pc == 0) {
$pcText = "<a href=http://www.yahoo.com'>yahoo.com</a>";

}

else if ($pc == 1) {
$pcText = "<a href='http://www.google.com'>Google.com</a>";
}

?>

 

there you go, i edited your php code, all you have to do is paste it

Edited by deathadder
  • 3 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.