我有以下搜索腳本,我需要將公司部分的結果鏈接到每個公司網站(存儲在我的數據庫的WEBSITE列中)。誰能幫忙?將超鏈接添加到回顯結果的PHP搜索腳本中
if(isset($_POST['completedsearch'])) {
$term = $_POST['query'];
$mysql = mysql_connect("ldb504.securepod.com","martindb","green11");
mysql_select_db("hcsd");
$qu = mysql_query("SELECT * FROM Sheet1 WHERE COMPANY LIKE '%".mysql_real_escape_string($term)."%' OR LOCATION LIKE '%".mysql_real_escape_string($term)."%' OR KEYWORDS LIKE '%".mysql_real_escape_string($term)."%' OR PRODUCTSSERVICES LIKE '%".mysql_real_escape_string($term)."%' "); //selects the row that contains ANYTHING like the submitted string
echo "Searching for '$term'";
echo "
<table><tr style=\"border-bottom:1px dotted #305896;\"><th style=\"padding:0px 10px;text-align:left;border-bottom:1px dotted #305896;\">Company</th>
<th style=\"padding:0px 10px;text-align:left;border-bottom:1px dotted #305896;\">Location</th>
<th style=\"padding:0px 10px;text-align:left;border-bottom:1px dotted #305896;\">Products/Services</th></tr>";
while($row = mysql_fetch_array($qu)) {
echo"<tr style=\"border-bottom:1px dotted #305896;\"><td style=\"padding:0px 10px;text-align:left;border-bottom:1px dotted #305896;\">";
echo"<a href="'.urlencode($row['WEBSITE']).'">'.htmlspecialchars($row['COMPANY']).'</a>";
echo "</td>";
echo "<td style=\"padding:0px 10px;text-align:left;border-bottom:1px dotted #305896;\">";
echo htmlspecialchars($row['LOCATION']);
echo "</td>";
echo "<td style=\"padding:0px 10px;text-align:left;border-bottom:1px dotted #305896;\">";
echo htmlspecialchars($row['PRODUCTSSERVICES']);
echo "</td></tr>";
}
echo "</table>";
}
你需要什麼樣的幫助?如果你有公司的網址,把公司名稱變成一個鏈接 - 你在幹什麼? – alexis
@alexis在下面的答案中看到我的評論。 – user2965329
很高興有人能夠幫助你!但這並不是一個好問題:未來,請具體說明問題,獲得幫助的機會會更高。 – alexis