global $wpdb;
$wpdb->get_results("SELECT * FROM wp_ap_promo WHERE wp_ap_promo.promocode = '".$promocode."' AND wp_ap_promo.business_id = " . $id .";");
echo $wpdb->num_rows;
My num_rows
always gives a 1, even though there are no results.
EDIT: seems like the problem was in my SQL-tables. But accepted answer also seems to work.
Try to
count()
the values instead.Like this:
if it still does not work, use something like this:
Hope this helps! 😀