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");