I am not able to insert hyperlink in php, the page goes blank when I insert the hyperlink in the way given below:
echo "' • {$row['ntitle']}: <a href=\"detail.php?id=' . $row['id'] . '\" class=\"style1\">Detail </a>'";
Please help me out to solve this problem
Your line contains errors related with the opening and close of quotes and double quotes.
This should do the work:
echo "• {$row['ntitle']}: <a href=\"detail.php?id={$row['id']}\" class=\"style1\">Detail </a>";
That should output something like:
• yourTitle: Detail
try this
echo "• ".$row['ntitle']." : <a href=\"detail.php?id='" . $row['id'] . "'\" class=\"style1\">Detail </a>";
your line have error, use the following lines to show the proper errors on php on the start of page.
ini_set('display_errors','1');
error_reporting(E_ALL & ~E_NOTICE);
your string is not correct quotted
try this instead of yours:
echo ' • '.$row["ntitle"].': <a href="detail.php?id=' . $row["id"] . '" class="style1">Detail </a>';
or use printf for not being confused by lots of quotes and concats:
printf(' • %s: <a href="detail.php?id=%s" class="style1">Detail </a>', $row["ntitle"], $row["id"]);
And definitely turn displaying errors/warnings/notices on http://www.php.net/manual/en/function.error-reporting.php.
Use sprintf function to format your string. Try this.
$string = sprintf(" • %s: <a href=\"detail.php?id=%s\" class=\"style1\">Detail </a>",$row["ntitle"],$row["id"]);
echo $string;