如何设置href标签来保存php变量,该变量包含指向其他站点的链接?

I have a mysql DB which directly stores links to different sites. I fetch the link from DB and store it in a variable like this:

$tdl = $row["file"];

Now this $tdl has the link to a different site... I use html tag to display it like this..:

<a href="<?php echo $tdl ;?>" target="_blank"><b><u>VIEW PDF DOCUMENT</b></u></a>

Now when i click on the link "VIEW PDF DOCUMENT" the new site is opened (eg http://www.IneedTOgoHERE.com). This works in local host but when I put my site online, It appends the link with my domain name, eg. http://www.myExampleDomain.com/www.IneedTOgoHERE.com.

I want to open just http://www.I need To go Here.com. How do I do that?

Try This,

<a href="<?php echo "http://".$tdl ;?>" target="_blank"><b><u>VIEW PDF DOCUMENT</u></b></a>

By the looks of it, your link is generating relative url links.

If $row["file"] doesn't include http in the database, you can hardcode that bit so it always shows. why not change your line to this?

<a href="http://<?php echo $tdl; ?>/" target="_blank">VIEW PDF DOCUMENT</a>
if(substr($tdl, 0, 4) != "http") {
  $tdl = "http://".$tdl;
}