Reputation: 300
maybe I am overlooking something painfully obvious, but here is my problem. I am selecting information from my database (which I know should return 4 results) and the select runs successfully but when I try to count the number of results I get a null.
I have the following in my php code
$query = "select ORDERS.order_id, PRODUCT.name, PRODUCT_ORDERS.quantity,
PRODUCT.sell_price, ORDERS.date from ORDERS, PRODUCT, PRODUCT_ORDERS where
ORDERS.order_id = PRODUCT_ORDERS.order_id AND PRODUCT.product_id =
PRODUCT_ORDERS.product_id and ORDERS.customer_id = $customer_id";
$results = mysqli_query($con, $query);
if (mysqli_query($con, $query)) {
echo "Successfully run query: $query";
} else {
echo "Invalid input error: " . $query . "<br>" . mysqli_error($con);
}
$num = mysqli_num_rows($result);
echo $num; //test to see if i get a number
I have used the same select statement in mysql workbench and it worked and returned 4 results as expected. Is there something specific in PHP that I should be looking out for? Thanks.
Upvotes: 2
Views: 449