[resolved] WPDB get_results, unable to get data formatted (2 posts)

  1. mobilemeneer
    Posted 3 years ago #

    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.

  2. mobilemeneer
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic