I have been stuck on this for about an hour and my hair is turning grey.
For some reason when I try to run this query:
$sql = "SELECT * FROM wp_units WHERE user_id = $user->ID AND post_units = $id";
$results = $wpdb->get_results($sql);
foreach ($results as $result) {
echo $result->post_units;
}
I get this output:
99 1212 1616 1919
In the database I have:
|id | user_id | post_units
1 1 9
2 1 12
3 1 16
4 1 19
Can anyone see why?
Edit:
$wpdb->last_query; also returns double the times.
SELECT * FROM wp_units WHERE user_id = 1 AND post_units = 9 SELECT * FROM wp_units WHERE user_id = 1 AND post_units = 9