Home > OS >  Want to make hyperlinks to html
Want to make hyperlinks to html

Time:11-09

I tried to add hyperlink to php but it's not working. Is there any mistakes ? `

echo "<td nowrap ".$rowspan.">\n";
      echo  "<font face=\"arial\" size=\"1\" color=\"#3C5F84\">\n";
      echo  "&nbsp " .$v["refno"].$v["barvalue"]. " &nbsp &nbsp ";
      echo  "</font>\n";
      echo "<a href=\"www.google.com\"></a>\n";
      echo  "</td>\n";

`

I tried to add the hyperlink to the current php code but it's not working either when I click.

CodePudding user response:

  1. You are missing text inside the hyperlink display
  2. You need to add http:// in order to visit an external link

So change the line

echo "<a href=\"www.google.com\"></a>\n";

to

echo "<a href=\"http://www.google.com\">google</a>\n";

So the code will be:

<?php
      echo "<table><tr><td nowrap ".$rowspan.">\n";
      echo  "<font face=\"arial\" size=\"1\" color=\"#3C5F84\">\n";
      echo  "&nbsp " .$v["refno"].$v["barvalue"]. " &nbsp &nbsp ";
      echo  "</font>\n";
      echo "<tr><td><a href=\"http://www.google.com\">google</a>\n";
      echo  "</td></table>\n";

?>

You may check the following Sandbox showing the result (values of $v["refno"] and $v["barvalue"] omitted):

http://www.createchhk.com/SOanswers/testSO9Nov2022b.php

CodePudding user response:

try this:

"<a href=//www.google.com></a>\n";
  • Related