Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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;
}
Source by wordpress.org #
 
PREVIOUS NEXT
Tagged: #php #wpdb #foreach
ADD COMMENT
Topic
Name
5+3 =