いくつかのオプションを試しましたが、最近成功しなかったため、助けを求めています。主な問題は、結果に「結果なし」という値が含まれていても、結果テーブルのヘッダーが常に表示されることです。テーブルのヘッダーなしで「結果なし」というメッセージのみが表示されるようにしたいだけです。
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 ";
}
}