Display Values from Custom Tables in wordpress Admin Panel
I would like to display some values from custom tables in wordpress. This is what I've got so far. I am not sure this is all completely correct.
function pr_forms() {
global $wpdb;
$table_name = pr_table_name();
return $wpdb->get_results( "SELECT id,name,place FROM $table_name" );
}
This will return multiple rows as an array. I tried using a foreach. But no use...it just gives an error.
Any suggestions how I can do this?开发者_JS百科
This works
function pr_forms() {
global $wpdb;
$table_name = pr_table_name();
$rows = $wpdb->get_results( "SELECT id,name,place FROM $table_name" );
foreach ($rows as $row) {
echo $row->id."<br>";
echo $row->name."<br>";
echo $row->place."<br>";
echo "<br>";
}
}
精彩评论