我创建了一个搜索框,它将从 MySQL 数据库中提取某些参数。如果没有出现参数导致回显文本通知用户没有匹配的参数可能很好,我需要将什么代码嵌入到以下代码中。
<?php
mysql_connect ("localhost", "root", "") or die (mysql_error());
mysql_select_db ("store_location");
$term = $_POST['term'];
$sql = mysql_query("SELECT * FROM store_location where store_name like '%$term%' or address like '%$term%' or city like '%$term%' or state like '%$term%' or zip like '%$term%' or phone like '%$term%' or fax like '%$term%' or email like '%$term%' or url like '%$term%' ");
echo '<h1>Search Results:</h1>';
while ($row = mysql_fetch_array($sql)){
echo 'Store Name: '.$row['store_name'];
echo '<br/> Address: '.$row['address'];
echo '<br/> City: '.$row['city'];
echo '<br/> State: '.$row['state'];
echo '<br/> Zip: '.$row['zip'];
echo '<br/> Phone: '.$row['phone'];
echo '<br/> Fax: '.$row['fax'];
echo '<br/> Email: <a href="mailto:'.$row['email'].'">'.$row['email'].'</a>';
echo '<br/> URL: <a href="'.$row['url'].'">'.$row['url'].'</a>';
echo '<br/><br/>';
}
?>