How to count number of records found in a database table?

Why don’t you directly echo the $num as it will contain the count of rows already…Here’s the edited part..

//To show number of rows in table
  function DB_Tables_Rows()
{
    global $wpdb;
    $table_name = $wpdb->prefix . 'mydata';
    $count_query = "select count(*) from $table_name";
    $num = $wpdb->get_var($count_query);

    echo  $num . 'Rows Found';


}