當我不嘗試使用 store_ID 進行搜索時,我的查詢有效。這是我所擁有的。<?php$search = $mysqli-> real_escape_string($_GET['store_ID']);$end = $mysqli-> real_escape_string($_GET['end']);$start = $mysqli-> real_escape_string($_GET['start']);$resultSet = $mysqli->query("SELECT * FROM orders INNER JOIN customers ON orders.store_ID=customers.store_ID WHERE order_date between '$start' and '$end' AND PurchaseMethod LIKE 'deferred"); if($resultSet-> num_rows>0){ while($rows = $resultSet->fetch_assoc()) { $storename= $rows['store_name']; $orderID = $rows['OrderID']; $storeID = $rows['store_ID']; $orderdate = $rows['order_date']; $purchaseMethod = $rows['PurchaseMethod']; $price = $rows['TotalPrice']; $output .= "<tr><td style='width:14.28%;'>$storename</td> <td style='width:14.28%;'>$orderID</td><td style='width:14.28%;'>$storeID</td> <td style='width:14.28%;'>$orderdate</td><td style='width:14.28%;'>$purchaseMethod</td> <td style='width:14.28%;'>$$price</td></tr>"; } }else{ echo var_dump($resultSet); $output = "No results"; } } ?> <?php echo $output; ?>這就是我想要開始工作的內容:$resultSet = $mysqli->query("SELECT * FROM orders INNER JOIN customers ON orders.store_ID=customers.store_ID WHERE order_date between '$start' and '$end' AND PurchaseMethod LIKE 'deferred' AND store_ID = '$search'");當我嘗試添加AND store_ID = '$search'");它時,它給了我這個錯誤:注意:嘗試在第 66 行的 customerreportC.php 中獲取非對象的屬性
1 回答

蝴蝶不菲
TA貢獻1810條經(jīng)驗 獲得超4個贊
由于 store_id 存在于兩個表中,它會給出不明確的錯誤。嘗試這個
$resultSet = $mysqli->query("SELECT * FROM orders
INNER JOIN customers
ON orders.store_ID=customers.store_ID
WHERE order_date between '$start' and '$end'
AND PurchaseMethod LIKE 'deferred' AND orders.store_ID = '$search'");
- 1 回答
- 0 關注
- 219 瀏覽
添加回答
舉報
0/150
提交
取消