我正在建立一個公交預訂系統,使用php & mysql。 在這裏,我試圖輸入搜索字段「路由」,這是mysql表的字段。 在搜索結果並將結果打印到頁面時似乎有問題。請幫助我。從Mysql數據庫創建一個php搜索
<?php
$connect=mysqli_connect("localhost","root","","tsms");
$output ='';
if(isset($_POST['from'])){
$searchq = $_POST['from'];
$query = mysqli_query("SELECT * FROM bus WHERE route='$serchq' ");
$count = mysqli_num_rows($query);
if($count==0){
echo "<script>
alert('No bus services are found');
</script>";
} else {
while($row = mysqli_fetch_array($query)){
$imageData = $row['image'];
$arrival = $row['arrival_time'];
$departure = $row['departure_time'];
$type = $row['bus_type'];
$class = $row['class'];
$name = $row['bus_name'];
$facilities = $row['facilities'];
$reservation = $row['reservation_fee'];
$output = '<div>'.$arrival.''.$departure.''.$type.''.$class.''.$name.''.$facilities.''.$reservation.'</div>';
}
}
}
echo $output;
?>
_它似乎有問題在搜索和打印_你能更具體嗎?順便提一下,你的問題對sql注入具有很高的潛力。 –
你是在說下拉搜索.. –
它沒有顯示任何結果。沒有錯誤也。 – ragnar1992