admin管理员组文章数量:1332334
So i'm trying to implement some custom doing a SELECT to a table i created.
I'm using the following:
global $wpdb;
$fivesdrafts = $wpdb->get_results("SELECT * FROM wpjk_vuln WHERE IDuser = " . um_profile_id());
foreach ( $fivesdrafts as $fivesdraft )
{
echo $fivesdraft->IDprogram;
}
When i open the page where the IDprogram should be displayed it isn't, not sure why.
BUT, if i add an echo with the query, bellow the code:
global $wpdb;
echo "SELECT * FROM wpjk_vuln WHERE IDuser = " . um_profile_id();
$fivesdrafts = $wpdb->get_results("SELECT * FROM wpjk_vuln WHERE IDuser = " . um_profile_id());
foreach ( $fivesdrafts as $fivesdraft )
{
echo $fivesdraft->IDprogram;
}
The page will display the IDprogram, it's just strange. I already hardcoded the um_profile_id() value and it happens the same thing.
So i'm trying to implement some custom doing a SELECT to a table i created.
I'm using the following:
global $wpdb;
$fivesdrafts = $wpdb->get_results("SELECT * FROM wpjk_vuln WHERE IDuser = " . um_profile_id());
foreach ( $fivesdrafts as $fivesdraft )
{
echo $fivesdraft->IDprogram;
}
When i open the page where the IDprogram should be displayed it isn't, not sure why.
BUT, if i add an echo with the query, bellow the code:
global $wpdb;
echo "SELECT * FROM wpjk_vuln WHERE IDuser = " . um_profile_id();
$fivesdrafts = $wpdb->get_results("SELECT * FROM wpjk_vuln WHERE IDuser = " . um_profile_id());
foreach ( $fivesdrafts as $fivesdraft )
{
echo $fivesdraft->IDprogram;
}
The page will display the IDprogram, it's just strange. I already hardcoded the um_profile_id() value and it happens the same thing.
Share Improve this question asked Jun 18, 2020 at 18:58 José CorreiaJosé Correia 1 1- Can you echo anything else from within the foreach to make sure the code is executing up to that point? – SeventhSteel Commented Jun 18, 2020 at 21:41
1 Answer
Reset to default 0If the IDuser
field is an integer, try:
$um_profile_id = um_profile_id();
$fivesdrafts = $wpdb->get_results("SELECT * FROM wpjk_vuln WHERE IDuser = $um_profile_id");
本文标签: databaseHelp with wpdb on custom code
版权声明:本文标题:database - Help with $wpdb on custom code 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742335784a2455593.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论