当我尝试执行查询并获取行数时,会生成错误。我已经尝试解决这个问题好几天了,而且我是 php 新手,所以它可能甚至不是语法问题。 <?php // error_reporting(0); $flying_from = ""; $flying_to = ""; $departure_date = ""; $return_date = ""; $number_of_adults = ""; $number_of_children = ""; $flight_class = ""; // Connect to database $conn = mysqli_connect('localhost', 'presh', '1234', 'saffron'); if (isset($_GET['submit'])) { $flying_from = $_GET['flying_from']; $flying_to = $_GET['flying_to']; $departure_date = $_GET['departure_date']; $return_date = $_GET['return_date']; $number_of_adults = $_GET['number_of_adults']; $number_of_children = $_GET['number_of_children']; $flight_class = $_GET['flight_class']; $query = "SELECT * FROM flights WHERE flying_from LIKE $flying_from AND flying_to LIKE $flying_to AND departure_date LIKE $departure_date AND return_date LIKE $return_date AND number_of_adults LIKE $number_of_adults AND number_of_children LIKE $number_of_children AND flight_class LIKE $flight_class"; $result = mysqli_query($conn,$query); $count = mysqli_num_rows($result); if($count > 0){ $output = 'There was no search results'; }else{ while ($row = mysqli_fetch_array($query)) { $fFrom = $row['flying_from']; $fTo = $row['flying_to']; $dDate = $row['departure_date']; $rDate = $row['return_date']; $nAdults = $row['number_of_adults']; $nChildren = $row['number_of_children']; $fClass = $row['flight_class']; $output .= '<div>'.$fFrom.' '.$fTo. ' '.$dDate.' '.$rDate.' '.$nAdults.' '.$nChildren.' '.$fClass.'</div>'; } }}?>
1 回答
宝慕林4294392
TA贡献2021条经验 获得超8个赞
您需要传递的$result
变量$query
不在mysqli_fetch_array()
while ($row = mysqli_fetch_array($result)) { }
- 1 回答
- 0 关注
- 137 浏览
添加回答
举报
0/150
提交
取消