$wpdb foreach

117

get_header();
function get_records()
{
	//$con=connectsql();
	$records=$wpdb->query("SELECT * FROM $wpdb->posts WHERE post_type = 'elements' AND post_status = 'publish'");
	$all=array();
	while($data=$records->fetch_assoc())
	{
		$all[]=$data;
	}
	return $all;
}
	$records=$wpdb->query("SELECT * FROM $wpdb->posts WHERE post_type = 'elements' AND post_status = 'publish'");

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

Comments

Submit
0 Comments