Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

How to echo a hyperlink?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

How to echo a hyperlink?

Postby jverner » Wed Sep 26, 2012 10:03 am

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>
jverner
New php-forum User
New php-forum User
 
Posts: 3
Joined: Mon Sep 24, 2012 2:52 pm

Re: How to echo a hyperlink?

Postby egami » Wed Sep 26, 2012 1:47 pm

Try this, may work out a bit better for you.


Code: Select all
<?php

if (isset($_POST['pc']))
{
  
$pc strip_tags($_POST['pc']);

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

  echo 
"Website: $pcText <br/>\r\n";
} else { 
  echo 
"Sorry, PC wasn't selected. So please try again.<br/>\r\n";
}
 
User avatar
egami
php-forum GURU
php-forum GURU
 
Posts: 2197
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot], Google Feedfetcher and 2 guests

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

cron