Answers for "php wpdb foreach"

PHP
0

php wpdb foreach

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;
}
Posted by: Guest on July-01-2020
0

$wpdb foreach

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

	while($data=$records->fetch_assoc())
	{
		print_r($data);
	}
	
}
Posted by: Guest on April-27-2020

Browse Popular Code Answers by Language