wpdb get results foreach

Solutions on MaxInterview for wpdb get results foreach by the best coders in the world

showing results for - "wpdb get results foreach"
Gabin
17 May 2020
1$results=$wpdb->get_results("SELECT * FROM your_table_name WHERE id LIKE' . $id . ';");
2foreach($results  as $key => $row) {
3// each column in your row will be accessible like this
4$my_column = $row->column_name;}
Jerri
03 Jan 2018
1
2	$records=$wpdb->query("SELECT * FROM $wpdb->posts WHERE post_type = 'elements' AND post_status = 'publish'");
3
4	while($data=$records->fetch_assoc())
5	{
6		print_r($data);
7	}
8	
9}