• Resolved hsysgrp

    (@hsysgrp)


    This a test page, do not know what is wrong, new at this.

    <!DOCTYPE html>
    <html>
    <head> Fetch data from table</head>
    </title>
    <body>
    <?php 
    global $wpdb; 
     $result = $wpdb->get_results( "SELECT ID,  FirstName, LastName from AAUW_Members order by LastName
    limit 4 ");
    foreach($result as $row)
    {
    echo $row[0];
    echo  $row[1];
    echo $row[2];
    }
    ?>
    </body>
    </html>

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Your Test Page’s source code looks messed up.
    Do you have a custom template with this source code or you just copy pasted this entire code in a new WordPress Page?

    Thread Starter hsysgrp

    (@hsysgrp)

    ” $wpdb object can be used to read data from any table in the WordPress database, not just those created by WordPress itself.” I wrote it on a new page. As I understand it, $wpdb points to the db for the site. Clearly I did not apply it correctly. here.

    Thread Starter hsysgrp

    (@hsysgrp)

    Figured it out, this code belongs on a new template page..

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘wpdb not working for me’ is closed to new replies.