Snatchy Posted January 27, 2008 Share Posted January 27, 2008 hey guys. i just can't seem to get this right. in the hall of fame i want to display not only the the posision of their userstats but the actual stat its self. function hof_strength() { global $db,$ir,$c,$userid, $myf; print "<table border=3 bgcolor=black> <tr><td><font color=green>[b]Showing the 20 users with the highest strength</td></tr></table> <table border=3 bgcolor=black> <tr><th><font color=yellow>[b]Posistion</th> <th><font color=yellow>[b]User</th> <th><font color=yellow>[b]Strength</th></tr>"; $q=$db->query("SELECT u.*,g.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN gangs g ON g.gangID=u.gang WHERE u.user_level != 0 $myf ORDER BY us.strength DESC,u.userid ASC LIMIT 20"); $p=0; while($r=$db->fetch_row($q)) { $p++; if($r['userid'] == $ir['userid']) { $t="[b]";$et="[/b]"; } else { $t="";$et=""; } print "<tr><td>$t$p$et</td> <td><font color=red>$t{$r['gangPREF']}</font> {$r['username']} [{$r['userid']}]$et</td> <td>{$r['strength']}</td></tr>"; } print "</table>"; } That's what is there so far. I thought {$r['strength']} would have worked, th table comes up right. i just can't get the stat to display. Cheers Snatchy Quote Link to comment Share on other sites More sharing options...
UCC Posted January 27, 2008 Share Posted January 27, 2008 Re: Which mysql query? SELECT u.*,g.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN gangs g ON g.gangID=u.gang So you're selecting everything from the users table, and the gang table. Joining Users, Userstats, and Gangs Why aren't you selecting anything from userstats if that is what you are trying to display? And why are you wasting processing power selecting the entire user record and gang record when you're only going to report on 1-2 fields? Quote Link to comment Share on other sites More sharing options...
Snatchy Posted January 28, 2008 Author Share Posted January 28, 2008 Re: Which mysql query? The gang table, users table and userstats tables are joined BECAUSE your in THE HALL OF FAME it displays your GANG TAG and your USERNAME and then sorts out whos got the most strength from highest to lowest with the USERSTATS table. ok now is all i want to do is display the amount of strength that the user that is displayed has. {$r['strength']} is what i added in to display the strength but it doesn't seem to work. It's doing my wig in. Can someone please help me with disp[laying the strength. Cheers Snatchy PS. Please don't answer me and try to make me look like a dumb ass like the last answer that wasn't actually an answer to the question that was asked. I felt that answer to my question was just a pick at me so I'm Picking Back. If you had of read the question right you would know that the script is the hall of fame and you would of also realised that you need to query all 3 tables for what you want displayed. Oh and other than the strength bit i have added it was original MC Code by Dabs so ya picking on his coding there.... Not mine. Cheers Snatchy Quote Link to comment Share on other sites More sharing options...
Nickson Posted January 28, 2008 Share Posted January 28, 2008 Re: Which mysql query? i think {$ir['strength']} will do it as it's the user data, not sure tho as i haven't looked into dbs for ages the normal query would be SELECT strenght FROM userstats WHERE id = $ir['userid'] (check the naming tho) Quote Link to comment Share on other sites More sharing options...
Snatchy Posted January 28, 2008 Author Share Posted January 28, 2008 Re: Which mysql query? if i do $ir instead of $r then it displays the user strength in all posistions and not all the different strengths. Quote Link to comment Share on other sites More sharing options...
UCC Posted January 28, 2008 Share Posted January 28, 2008 Re: Which mysql query? You're a fucking loser Snatchy. I solved your damn problem but you are too stupid to understand what I said. You are a dumb ass THIS, YOUR CODE, IS WRONG (Insufficient anyway) SELECT u.*,g.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN gangs g ON g.gangID=u.gang WHERE u.user_level != 0 $myf ORDER BY us.strength DESC,u.userid ASC LIMIT 20 THIS, IF YOU HAVE HAVE A BRAIN TO COMPREHEND WHAT I SAID is Correct. SELECT u.*,g.*, us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN gangs g ON g.gangID=u.gang WHERE u.user_level != 0 $myf ORDER BY us.strength DESC,u.userid ASC LIMIT 20 Now go back to sucking on your moms tit and come back when you grow up Quote Link to comment Share on other sites More sharing options...
Isomerizer Posted January 29, 2008 Share Posted January 29, 2008 Re: Which mysql query? ROFL Quote Link to comment Share on other sites More sharing options...
Vyp3r2oo9 Posted January 29, 2008 Share Posted January 29, 2008 Re: Which mysql query? ROFL I Second that! Lol - release the frustration! Quote Link to comment Share on other sites More sharing options...
UCC Posted January 29, 2008 Share Posted January 29, 2008 Re: Which mysql query? And people wonder why I rarely help, it's because of this kinda thing.... Quote Link to comment Share on other sites More sharing options...
Jesse60905 Posted January 30, 2008 Share Posted January 30, 2008 Re: Which mysql query? Wow.. I came back for this... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.