Greetings mates,
I am trying to join 3 tables together which is kinda working but not lol its not displaying the users names that done reports for the month. here is the script..
$query_users = "SELECT user_name FROM users ORDER BY user_name";
$result_users = mysql_query($query_users);
while ($line = mysql_fetch_array($result_users)) {
$user_name = $line['user_name'];
$total = 0;
$query_scores = "SELECT r1.total, r1.bonus, r2.total2, r2.bonus2, r3.total3, r3.bonus3
FROM reports as r1
JOIN reports2 as r2 ON r1.user_name = r2.user_name
JOIN reports3 as r3 ON r3.user_name = r2.user_name
WHERE MONTH(r1.date)=$today_month AND YEAR(r1.date)=$today_year AND MONTH(r2.date)=$today_month AND YEAR(r2.date)=$today_year AND MONTH(r3.date)=$today_month AND YEAR(r3.date)=$today_year";
$result_scores = mysql_query($query_scores) or die(mysql_error());
while ($line = mysql_fetch_array($result_scores)) {
$total_score2 = $line['total'];
$bonus = $line['bonus'];
$total_score = $bonus + $total_score2;
$total += $total_score;
}
$top_scorers[$user_name] = $total;
$month_total += $total;
}
its not even getting stuff from reports2 and reports3 and im thinking $user_name is something to do with that :-\