Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Monthly total - 3 tables joined
Old 09-14-2008, 04:19 PM Monthly total - 3 tables joined
Novice Talker

Posts: 11
Trades: 0
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..

PHP Code:
$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 :-\
__________________
~Fear the one they call Smackie for thy who tries and kills thee thy will be died before sunrise Death 10:1~
Smackie is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-15-2008, 01:21 AM Re: Monthly total - 3 tables joined
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
RTFM about left join
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Reply     « Reply to Monthly total - 3 tables joined
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09814 seconds with 12 queries