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.

Read More

Any suggestions how I can do this?

Related posts

Leave a Reply

1 comment

  1. 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>";
        }
    }