wpdb Cannot Access Associative Array Data in a Count Query

You can simplify that by using $wpdb->get_var. $total = $wpdb->get_var( “SELECT COUNT( * ) AS total FROM tableA” ); echo “Total Records:” . $total; However, the code you’ve got should work– either version of it. I tested both. The only thing I notice is that the first version of the code should give you Array … Read more

wpdb select from using array as search parameters

Pass your information through prepare as in this example from the Codex: $metakey = “Harriet’s Adages”; $metavalue = “WordPress’ database interface is like Sunday Morning: Easy.”; $wpdb->query( $wpdb->prepare( ” INSERT INTO $wpdb->postmeta ( post_id, meta_key, meta_value ) VALUES ( %d, %s, %s ) “, array( 10, $metakey, $metavalue ) ) ); Your array should have … Read more

Can’t print out returned value

Correct way to get the ratings for individual authors. This is for the author.php page. If you want to display it elsewhere on your site, for example to show the number of likes for the currently logged in user, then use get_current_user_id( ‘ID’ ); in place of get_the_author_meta. <?php function author_rating_total() { $user_id = get_the_author_meta( … Read more