I have a WordPress page that connects to an external database from WordPress using the following code:
$my_wpdb = new wpdb('me', 'password', 'database', 'localhost');
$myrows = $my_wpdb->get_results( "SELECT Name FROM testing" );
…then i use print_r($myrows);
and get the following:
Array
(
[0] => stdClass Object (
[Name] => Jesus
)
[1] => stdClass Object (
[Name] => James
)
[2] => stdClass Object (
[Name] => Matt
)
)
Now I need to output the names inside those objects in a select tag using php.
Any help would be appreciated.
There you go:
Also, by the looks of your table it might be easier to just use WordPress
get_col()
function, which works pretty much the same way asget_results
but should directly return “Name”.EDIT – Maybe the [insertphp] plugin likes this version better:
Also, please provide any error info that might help troubleshoot the problem otherwise.