My query works when I don't try to search using the store_ID. Here is what I have that works.
<?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; ?>
This is what I'm trying to get to work:
$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'");
When I try to add the AND store_ID = '$search'");
it gives me this error:
Notice: Trying to get property of non-object in customerreportC.php on line 66