In Function.php, I want to check if my variable exist in a table of wordpress database, but it don't work.
global $wpdb;
$count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->pincode_distro1 WHERE pincode = $the_order->shipping_postcode"));
if($count == 1) { echo 'distro 1'}
else { echo 'distro 2'}
I guess you won't need $wpdb->prepare() for that, tried this way?
remove
$wpdb
from table name . Code will workfrom
to