我正在研究PHP/Ajax functions at W3schools.com。該源代碼對我來說很棒。但該代碼沒有超鏈接功能。所以我想從URL中的q參數創建一個超鏈接。如何修改gethint的PHP代碼?
所以我爲此做了PHP代碼。但我很長一段時間都處於虧損狀態。 以下是我的PHP代碼。
// Get the q parameter from URL
$q = $_REQUEST["q"];
$hint = "";
// Lookup all hints from array if $q is different from ""
if ($q !== "")
{
$q = strtolower($q);
$len = strlen($q);
foreach($a as $name)
{
if (stristr($q, substr($name, 0, $len)))
{
if ($hint === "")
{
$hint = $name;
echo '<a href="http://www.naver.com/"'$hint">" $hint"</a>";
}
else
{
$hint .= ", echo '<a href="http://www.naver.com/"'$hint">" $hint"</a>";
}
}
}
}
// Output "no suggestion" if no hint were found
// or output the correct values
echo $hint==="" ? "no suggestion" : $hint;
?>
我怎樣才能使A HREF =「HTTP:// WWW ...超級鏈接$提示或$名稱
不要使用w3schools,請看這個鏈接更多http://www.w3fools.com/ –