Here is what I am trying to acheive on my wordpress site.
I would like to compare 2 data sources from 1 database. For example when a random wordpress user logs in, I would like PHP to get his user ID and then check if that ID matches with other table's ID and then if they match display content in frontend according to matched ID.
Table 1 is wordpress wp_users and table 2 is a table which has its own id and contains data. Data which table 2 contains is related to wordpress users. Each wordpress has its own data.
I need to display this data in frontend of the website after matching validation is done.
I managed to display data in front end but stuck in comparing two tables.
Here is what I got:
$user = get_userdata($user_id);
$h5p = $wpdb->get_var("SELECT id FROM wp_h5p_results ");
if ($user == $h5p) {
$total_score = $wpdb->get_var("SELECT score FROM wp_h5p_results ");
echo "<p>Your Score {$total_score}</p>";
} else {
echo 'No user with such ID';
}