简而言之,我有一个 PHP 输出(代码只是一部分),在网页上显示时需要超链接,但问题是,当没有结果时,它会超链接一个空白 URL。如果执行搜索时没有结果,是否仍然不显示 HTML?
为了澄清,我需要将此应用于输出的多个部分。
这是代码的特定部分。
if(isset($_POST['search'])) {
$searchq = $_POST ['search'];
$query = mysql_query ("SELECT * FROM HH_list2 WHERE Company LIKE '%$searchq%'") or die ("could not search"); //OT TO HERE !!!!!
$count = mysql_num_rows($query);
if ($count == 0) {
$output = 'Sorry but we did not find anything';
}else{
while($row = mysql_fetch_array($query)) {
$Company = $row ['Company'];
$Twitter_ID = $row ['Twitter_ID'];
$Online_chat = $row ['Online_chat'];
$Online_form = $row ['Online_form'];
$Email_1 = $row ['Email_1'];
$Email_2 = $row ['Email_2'];
$Email_3 = $row ['Email_3'];
$output .= '<div style="background-color:#ebebeb; padding: 2em;"> <h3>'.$Company.' </h3><br/> Twitter: <a href="http://www.twitter.com/'.$Twitter_ID.'" target="_blank">'.$Twitter_ID.'</a><br/> <a href="'.$Online_chat.'" target="_blank">Online Chat</a> <br/> <a href="'.$Online_form.'" target="_blank">Online Form</a><br/>'.$Email_1.'<br/>'.$Email_2.'<br/>'.$Email_3.'</div>';
}
}
}