Jump to content
MakeWebGames

Which mysql query?


Snatchy

Recommended Posts

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...