I made a custom wp table,
but there is a problem. Count rows doesn’t work carefully.
All of this variable return 0,
but you can see in my table we have 3 record with read = 1.
(read=1 : read ,read = 2 : unread)
$table_name = $wpdb->prefix . 'inbox';
$inbox_rows = $wpdb->get_var("SELECT COUNT(*) FROM $table_name where type= 1 ");
$unread1 = $wpdb->get_var("SELECT COUNT(*) FROM $table_name WHERE 'read'= 1 and type = 1 ");
$unread2 = $wpdb->get_var("SELECT COUNT(*) FROM $table_name WHERE 'read'= 1 and type = 2 ");
$result = $wpdb->get_var("SELECT COUNT(*) FROM $table_name where 'read'= 1 ");
/*
|------|------|
| read | type | both of them are int (in phpmyadmin)
|------|------|
| 2 | 1 |
|------|------|
| 1 | 1 |
|------|------|
| 1 | 2 |
|------|------|
| 1 | 1 |
|------|------|
*/
Please help me.
I think u missing the $wpdb global declare like below code: