wpdb get results foreach
snippet in php

wpdb get results foreach

user2842

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

$wpdb foreach

user5741


	$records=$wpdb->query("SELECT * FROM $wpdb->posts WHERE post_type = 'elements' AND post_status = 'publish'");

	while($data=$records->fetch_assoc())
	{
		print_r($data);
	}
	
}

wpdb get results foreach

user1450

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

$wpdb foreach

user8438


	$records=$wpdb->query("SELECT * FROM $wpdb->posts WHERE post_type = 'elements' AND post_status = 'publish'");

	while($data=$records->fetch_assoc())
	{
		print_r($data);
	}
	
}