WordPress.org

Ready to get started?Download WordPress

Forums

Cannot output database entries. (3 posts)

  1. JohnnyWhite2007
    Member
    Posted 4 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;
    }
    }

    retrieve_requests();

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

  3. JohnnyWhite2007
    Member
    Posted 4 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

Tags

No tags yet.