Jump to content

can anyone tell me whats wrong with my query?


Greysoul

Recommended Posts

i'm guessing its because i have it defining gp and score, and then using the two in a math problem directly after.  if this is wrong, how would i go about correcting it?

 

fyi...

gp=games played, its tallying the amount of times the player is listed to say how many games they played in. 

score=a score of kills after deaths, its just a number

spg=of course is average score per games played in

 

function pspg(){
$score=mysql_query("SELECT *, COUNT(Player) AS gp, SUM(Score) AS score, (score/gp) AS spg FROM Scorecard WHERE score > 0 GROUP BY Player ORDER BY spg DESC Limit 0,10");
echo "<table>";
echo "<tr>
<th class='th'>Rank</th>
<th class='th'>Pilot</th>
<th class='th'>Clan</th>
<th class='th'>GP</th>
<th class='th'>SPG</th></tr>";
while($ps=mysql_fetch_array($score)){
echo "<tr>";
echo "<td class='tdp'>" . ++$i . "</td>";
echo "<td class='tdp'>" . '<a href=o.php?p=' . $ps['Player'] . '>' . $ps['Player'] . '</a>' . "</td>";
echo "<td class='tdp'>" . '<a href=o.php?c=' . $ps['Clan'] . '>' . $ps['Clan'] . '</a>' . "</td>";
echo "<td class='tdp'>" . $ps['gp'] . "</td>";
echo "<td class='tdp'>" . round($ps['spg'], 2) . "</td>";
echo "</tr>";
}
echo "</table>";
echo "<br>";
}

Link to comment
Share on other sites

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/greysoul/public_html/o/leaders.php on line 99

 

and if i change to mysql error...

 

Unknown column 'gp' in 'field list'

 

so yeah its pulling from the table in that division instead of the alias i assigned

Link to comment
Share on other sites

i just realized later on i will need to set a minimum of games played..like when there's 10 games played i'd need only players with a minimum of 4 games played to be eligible to be shown. if i change my where clause to...WHERE gp > 3...it just says gp is an unknown column. if i say WHERE Count(Player) > 3..it says invalid group function or something.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.