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... Did I miss something? (I'm new on wordpress)
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... Did I miss something? (I'm new on wordpress)
Share Improve this question asked Jul 7, 2020 at 5:35 MuhazaMuhaza 152 bronze badges1 Answer
Reset to default 0$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
"
);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742286186a4415362.html
评论列表(0条)