• Resolved musichappens

    (@musichappens)


    Evening all,

    I am having an issue with this particular query. It works for certain tables (like the users table), but not the one listed in the code. When I query the users table, it retrieves a number (the number of rows, as it’s supposed to). However, when I query the fm_data_1 table, it does not return anything.

    I have tried everything I can think of, and cannot seem to get it to work. Any suggestions would be greatly appreciated!

    function displayText($rowCount){
    global $wpdb;
    $row = $wpdb->get_var( 'SELECT COUNT(*) FROM $wpdb->fm_data_1' );
    echo "The count of rows is {$row}";
    }
    
    add_filter('the_content','displayText');
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter musichappens

    (@musichappens)

    Let me also say that the users table is the one created by WordPress. The fm_data_1 table was created by a plugin.

    Thread Starter musichappens

    (@musichappens)

    Figured it out! Had to include this snippet of code to define the custom table in the class:

    $wpdb->fm_data_1 = $wpdb->prefix.'fm_data_1';

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Database Count Query Not Returning Results’ is closed to new replies.