Preview:
USE GET_VAR() TO RETURN A SINGLE VALUE
<?php
$customer_count = $wpdb->get_var(“SELECT COUNT(*) FROM laundry_customers;”);
echo ‘<p>Total customer: ‘ . $customer_count . ‘</p>’;
?>


USE GET_ROW() TO RETURN A SINGLE ROW OF DATA
<?php
$mycustomer = $wpdb->get_row('SELECT * FROM laundry_customers WHERE ID = 1');
echo $mycustomer -> customer_name;
?>


USE GET_RESULTS() TO RETURN MULTIPLE ROWS OF DATA
<?php
$allcustomers = $wpdb->get_results('SELECT customer_name, customer_id FROM laundry_customers WHERE status = 1');
foreach ($allcustomers as $singlecustomer ) {
echo '<p>' .$singlecustomer->customer_name. '</p>';
echo '<p>' .$singlecustomer->customer_id. '</p>';}
?>
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter