Cannot output database entries. (3 posts)

  1. JohnnyWhite2007
    Posted 6 years ago #

    I am trying to request things from the database. But it does not working. Is there anything I am doing wrong? If so how would I get the information from the database and display it on a page.

    function retrieve_requests(){
    global $wpdb;

    $query = ("SELECT id, name, request FROM $wpdb->my_table ORDER BY id");

    $rows = $wpdb->get_results($query, OBJECT);

    foreach($rows as $row){
    echo $row->id;
    echo $row->name;
    echo $row->request;


  2. James Huff
    Support Team Rep.
    Posted 6 years ago #

    Can you let us know what you're trying to do, as there is probably already an internal function for it.

  3. JohnnyWhite2007
    Posted 6 years ago #

    Ok let me give the rundown.

    PLUGIN (Admin Panel)
    --PLUGIN (Sub-panel that displays entries in the database, doesn't work)
    --ADD Entry(Sub-panel adds entries in the database, this works)

    The page that the plugin is suppose to display the entries in the table. It would display it as:

    Name ----- Request
    John Doe - Please remember to take the trash out.

    The function above is suppose to connect to the database and then select the table and get the rows and display them on the page.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.