Jump to content

Sort by a math variable inside of a while loop


Recommended Posts

i'm trying to sort by a math variable included in a while loop. obviously if i declare the variable in a loop called from a query...i can't use the order by in the query, or if i can i'm not sure how as i've tried a couple of ways. i've also tried to use sort($kpg) and that didn't quite work as well as i'd hoped. i'm a bit clueless here.

function pkpg(){$score=mysql_query("SELECT * FROM Players WHERE Kills > 0 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'>KPG</th></tr>";while($ps=mysql_fetch_array($score)){echo "<tr>";echo "<td class='tdp'>" . ++$i . "</td>";echo "<td class='tdp'>" . $ps['Player'] . "</td>";echo "<td class='tdp'>" . $ps['ClanName'] . "</td>";echo "<td class='tdp'>" . $ps['GP'] . "</td>";$kpg= $ps['Kills'] / $ps['GP'];echo "<td class='tdp'>" . $kpg . "</td>";echo "</tr>";}echo "</table>";echo "<br>";}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...