Tuesday, 7 July 2020

Echo won't render data from Wordpress Mysql

When I used this code, the result/echo display as I wanted.

<?php
$user_checks = $wpdb->get_results( 
    "
    SELECT ID, user_nicename
    FROM $wpdb->users
    "
);

foreach ( $user_checks as $user_check ) 
{
    echo $user_check->ID;
    echo $user_check->user_nicename;
}
?>

But when I choose table other then what wordpress provide e.g:

<?php
    $user_checks = $wpdb->get_results( 
        "
        SELECT id, name
        FROM $wpdb->uap_banners
        "
    );

    foreach ( $user_checks as $user_check ) 
    {
    echo $user_check->id;   
    echo $user_check->name;
    }
    ?>

The Result is blank...

I ask Wordpress community to help me

https://wordpress.stackexchange.com/questions/370534/when-wordpress-default-table-echo-success-when-plugin-table-echo-blank


and I got feedback from 



he said

$wpdb does not contain any reference to custom tables. So the uap_banners property doesn't exist. You need to write in the table name the say way it was written when creating the table. So in your case that would probably be (assuming you included the database prefix):

$user_checks = $wpdb->get_results( 
    "
    SELECT id, name
    FROM {$wpdb->prefix}uap_banners
    "
);
The problem solved

email mailto: pretext

 <a href="mailto:designoutsourced.com+info@gmail.com?subject=Maklumat%20lanjut%20pakej&body=Hai,%20saya%20berminat%20tahu%20lebi...