0

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.

1
  • Can you echo anything else from within the foreach to make sure the code is executing up to that point? Jun 18, 2020 at 21:41

1 Answer 1

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.