How to parse row results from $wpdb -> get_results

I have the following:

$query = 'SELECT * FROM wp_pod_tbl_add_questions WHERE id LIKE '. $id;

                                        $row = $wpdb -> get_results($query);

How do I get the columns named ‘id’ and ‘name’ from $row?

4

foreach( $wpdb->get_results("SELECT * FROM your_table_name WHERE id LIKE' . $id . ';") as $key => $row) {
// each column in your row will be accessible like this
$my_column = $row->column_name;}

More info here

Leave a Comment