Using PHP how can I get this web link with _blank to work for my needs?

  • Thread starter Thread starter Ryan
  • Start date Start date
R

Ryan

Guest
I have the below code working the way I want it to but i want to use $url for the adress and $title for the visible text

<?php

echo "<a href=\"http://www.mywebpage.com\"
target=\"_blank\">Visit my web page</a>";

?>
1 hour ago - 3 days left to answer.
 
<?php

// if you have it from database, execute a query. pass the url and title value to the variable as shown below.

$results=mysql_query("select * from mytable");
$row=mysql_fetch_array($results);

$url=$row['url'];
$title=$row['title'];

otherwise, just use it like this:
$url="http://www.mywebpage.com";
$title="Visit My Homepage";

echo "<a href=\"$url\" target=\"_blank\">$title</a>";

?>
 
Much easier not to escape all those quotes. Only the url and title need to be in php.

<a href="<?php echo $url; ?>" target="_blank"><?php echo $title; ?></a>
 
<?php

// if you have it from database, execute a query. pass the url and title value to the variable as shown below.

$results=mysql_query("select * from mytable");
$row=mysql_fetch_array($results);

$url=$row['url'];
$title=$row['title'];

otherwise, just use it like this:
$url="http://www.mywebpage.com";
$title="Visit My Homepage";

echo "<a href=\"$url\" target=\"_blank\">$title</a>";

?>
 
Back
Top