Ive been trying with no success to turn the result of a simple MySQL query that looks at one column and returns all of the items in a column, using WordPress’ built in db class, into a simple array.
I found one other similar post that kind of helped, it changed the array, but still didnt provide the result I’m looking for.
I’m trying to archive this simple one-dimensional array:
Array (  => cat  => dog )
So far, manipulating the various wpdb query options, I’ve gotten this:
Array (  => Array (  => cat )  => Array (  => dog ) )
Array (  => Array ( [id] => 14 [mysql-field] => cat )  => Array ( [id] => 15 [mysql-field] => dog ) )
The query is simple enough:
$sql = "SELECT animals from $table_name"; $pets = $wpdb->get_results($sql);
Am I missing something really simple here? Or can anyone lend some advice?
- The topic ‘turn wpdb->get_results…. into a single dimensional array’ is closed to new replies.