$wpdb->get_var not returning count

In your code it is actually counting the query you have inserted in $testargs. In your case you entered one. So it is giving you back one. If you need to get the count on WordPress users table then write the query like below- global $wpdb; $total_query = “SELECT COUNT(*) FROM {$wpdb->users} AS total_count”; $total … Read more

Add row to SQL array

What about something like this ? $custom_row = array(array(‘race_id’ => ‘1’, ‘race_name’ => ‘2’, ‘race_date’ => ‘3’)); $races = $wpdb->get_results(” select r.race_name ,r.race_id ,date_format(r.race_date,’%c.%d.%Y’) race_date from race_calendar r order by r.race_date; “, ARRAY_N); $merged_arr = array_merge($custom_row, $races); foreach ( $merged_arr as $race ) { echo $race[‘race_id’] . ‘,’ . $race[‘race_name’] . ‘,’ . $race[‘race_date’]; } … Read more

How do I insert content of various MySQL fields in post?

I also would vote for creating a short code. The shortcode code could pull data from a database/table, and ‘build’ the text you want with values from the table. Lots of googles on how to build shortcodes – check those out, vs me putting some sample code here. You would put the shortcode function in … Read more