我想知道当我寻找的名字不存在时,我如何在搜索脚本中写一条消息。 我的脚本告诉我这个' 0结果' name'"我想写自己的信息, 这是我的PHP代码:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$search_output = "";
if (isset($_POST['searchquery']) && $_POST['searchquery'] !="" ){
$searchquery = preg_replace('#[^a-z 0-9?!]#i', '', $_POST['searchquery']);
if($_POST['filter1'] == "Nom de medicament"){
$sqlCommand = "(SELECT COL_8, COL_17 AS medicament, COL_32 FROM tbl_name WHERE COL_17 LIKE '%$searchquery%' ) ";
}
mysql_connect('localhost','root','');
mysql_select_db('signup');
$query = mysql_query($sqlCommand) or die(mysql_error());
$count = mysql_num_rows($query);
$search_output .= "<hr />$count results for <strong>$searchquery</strong><hr/>$sqlCommand<hr />";
while($row = mysql_fetch_array($query)){
$COL_8 = $row["COL_8"];
$medicament = $row["medicament"];
$COL_32 = $row["COL_32"];
$search_output = "Prix: $COL_8 - $medicament - Quantité: $COL_32 <br/>";
} // close while
}
?>
有人可以帮助我。
答案 0 :(得分:0)
您只需更改此行
即可$search_output .= "<hr />$count results for <strong>$searchquery</strong><hr/>$sqlCommand<hr />";
到
$search_output .= "<hr />Your own message<hr/>$sqlCommand<hr />";
随意使用$count
和$searchquery
这些变量包含结果数(无)和搜索过的名称。