我正在寻求帮助,因为我尝试了几种选择,但最近没有成功。主要问题是结果表的标题始终显示,即使结果的值为“无结果”,我只想在没有表标题的情况下出现“无结果”消息。
if (preg_match("/^[ a-zA-Z]+/", $_POST['search'])) {
$name=$_POST['search'];
$sql="SELECT airport_id, airport_name, region_name, airport_code, island_name FROM airport, region, island WHERE airport_name LIKE '" . $name . "%' AND region_id=airport_region AND island_id=airport_island";
$result=mysql_query($sql);
$n=0;
//* here is the table header with echo //should not be visible when $n=0
while ($row=mysql_fetch_array($result)) {
$id_airport=$row['airport_id'];
extract($row);
//*result of table when $n>=0 with the header of the table//
++$n;
}
if (0 == $n) {
echo " no result ";
}
}