I wrote a search script, but when you enter an empty value, the entire table is displayed, as this, instead of the entire table, output a message like "Request is empty
<?PHP header("Content-Type: text/html; charset=utf-8");?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php // определяем начальные данные $db_host = 'localhost'; $db_name = 'terminal'; $db_username = 'hsa89'; $db_password = '97153hsa'; $db_table_to_show = 'kvitancii'; $str=iconv("UTF-8", "CP1251", $_POST['str']); $select = mysql_query ("INSERT INTO `comment` (`str`) VALUES ('".$str."')"); // соединяемся с сервером базы данных $connect_to_db = mysql_connect($db_host, $db_username, $db_password) or die("Could not connect: " . mysql_error()); // подключаемся к базе данных mysql_select_db($db_name, $connect_to_db) or die("Could not select DB: " . mysql_error()); // выбираем все значения из таблицы $qr_result = mysql_query("SELECT id, fio, adres, kod FROM kvitancii WHERE(id) LIKE '%".strtoupper($_POST['nmag'])."%'") or die(mysql_error("Запрос ошибочный")); // выводим в HTML-таблицу все данные клиентов из таблицы MySQL if (mysql_num_rows($qr_result) > 0){ while($data = mysql_fetch_array($qr_result)){ echo "<table width='596' align='center' border='1' cellpadding='1' style='border-collapse: collapse; border: 1px solid white;'> <tr> <td colspan='3' rowspan='5' align='center' valign='top'>ИЗВЕЩЕНИЕ Ф1</td> <td colspan='2' border:'1px solid black'>" . $data['fio'] . "</td> <td colspan='2'>" . $data['id'] . "</td> </tr> <tr> <td colspan='4'>" . $data['adres'] . "</td> </tr> <td colspan='4' padding='3px' style='font-family:Barcode; src:url(fonts/Barcode.ttf); font-size:30pt'>00:08020:0288022800::022808:000:::00020</td> </tr> "; echo '</table> '; }} elseif (mysql_num_rows($qr_result)<=0) { echo "<div>НАЗАД ↻</a></div>"; } else {echo 'jib,rf';} // закрываем соединение с сервером базы данных mysql_close($connect_to_db); ?>