[ad_1]
I have register a table on WordPress and assume the table name is my_table and so far it looks like below:
| id | name |
| — | ———- |
| 1 | apple |
| 2 | orange |
| 3 | watermelon |
How do I get all the value from name as an array like below?
$data = array( 'apple', 'orange', 'watermelon');
I have tried the below code but it just show/print the word Array
global $wpdb;
$table_name = $wpdb -> prefix . 'my_table';
$data = $wpdb -> get_results ( $wpdb -> prepare ( "SELECT name FROM $table_name" ) );
echo $data;
