Reputation: 9
I am using a theme that i installed and activated in wordpress .The theme is Zerif-lite.
I added a table to the database named "doctors" with 2 attributes "id" and "name". What I'm trying to do is to select all data in this table. I've used the following code but nothing is displayed
$mystuff = $wpdb->get_row("SELECT * FROM doctors WHERE 1);
Any Help??
Upvotes: 0
Views: 113
Reputation: 873
try this
global $wpdb;
$result = $wpdb->get_results("select * from `table_name` where column = value");
foreach($result as $results){
echo $results->field1;
echo $results->field2;
}
Upvotes: 1
Reputation: 2942
try this:
global $wpdb;
$result = $wpdb->get_results("select * from `table_name`");
foreach($result as $row){
echo $row->field1;
echo $row->field2;
echo $row->field3;
}
Upvotes: 0