WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] WPDB get_results, unable to get data formatted

[Resolved] WPDB get_results, unable to get data formatted

  • Hi Guys,

    I’m using a custom table in my wordpress database and am using wpdb to query the complete content of this table.

    This is what i am using:

    global $wpdb;
    $allposts= $wpdb->get_results("SELECT * FROM test", ARRAY_A);
    echo '<table>';
    foreach ($allposts as $key => $value){
    echo '<tr>';
    echo '<th>' .$value["test"]. '</th>';
    echo '<th>' .$value["test1"]. '</th>';
    echo '<th>' .$value["test2"]. '</th>';
    echo '<th>' .$value["test3"]. '</th>';
    echo '<th>' .$value["test4"]. '</th>';
    echo '</tr>';
    }
    echo '</table>';

    Unfortunately i can’t get this data in the correct format. All de information is displayed without enters and doesn’t seem to accept my table, th etc.

    What am i doing wrong?

    I’m using a plugin to be able to enter php code in my wordpress page.

    Any help will be appriciated, Many thanks in advance.

Viewing 1 replies (of 1 total)
  • I solved the issue. It was caused by a plugin named “Use php in your posts” or st.

    So don;t use it, just stick to the good old Exec_PHP plugin to use php code on the pages.

    This issue really got me stuck for a week.

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] WPDB get_results, unable to get data formatted’ is closed to new replies.
Skip to toolbar