WordPress.org

Ready to get started?Download WordPress

Forums

wpdb mysql_num_rows? (6 posts)

  1. Anthony
    Member
    Posted 2 years ago #

    How do I use wpdb to get the number of rows in a table?

  2. Jackson
    Member
    Posted 2 years ago #

    The results count for a 'SELECT' query will be stored in $wpdb->num_rows.

    http://codex.wordpress.org/Class_Reference/wpdb

  3. Anthony
    Member
    Posted 2 years ago #

    Is it possible that you post an example?

  4. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    http://wp.smashingmagazine.com/2011/09/21/interacting-with-the-wordpress-database/

    Here's a killer article which may have some help too

  5. Jackson
    Member
    Posted 2 years ago #

    The smashing article is a great resource.

    You need to make a query, then access the variable with the number of rows, ie:

    global $wpdb;
    $wpdb->get_results( 'SELECT COUNT(*) FROM table_name' );
    echo  $wpdb->num_rows . 'Rows Found';
  6. Anthony
    Member
    Posted 2 years ago #

    Thank you guys very much!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.