netman182 Posted June 7, 2010 Share Posted June 7, 2010 I am having a problem with a list i have tabel. I am trying to have the players names come up in order of the most amount of points. it is not working the way i want it to and i am having problems doing it. can anyone give some help? eg. here is what i want: name: pts: player 4 45 player 3 31 player 2 20 player 1 3 player 5 1 here is what it is it shows : http://www.bccsl.org/stats/2010/scoring/thrsou.php as you notice it is showing them in the wrong order. here is my code: <?php $con = mysql_connect("localhost","*********","******"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("***********", $con); $result = mysql_query("SELECT * FROM players WHERE division='thrsou' AND point >= '1' ORDER BY point DESC "); echo "<table border='1'> <tr> <th><div align='center'>Name</div></th> <th><div align='center'>Team</div></th> <th><div align='center'>Games Played</div></th> <th><div align='center'>Goals</div></th> <th><div align='center'>Assists</div></th> <th><div align='center'>Points</div></th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td><div align='center'>" . $row['first'] . " " . $row['last'] . "</div></td>"; echo "<td><div align='center'>" . $row['teamname'] . "</div></td>"; echo "<td><div align='center'>" . $row['gp'] . "</div></td>"; echo "<td><div align='center'>" . $row['goal'] . "</div></td>"; echo "<td><div align='center'>" . $row['assist'] . "</div></td>"; echo "<td><div align='center'>" . $row['point'] . "</div></td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Link to comment https://forums.phpfreaks.com/topic/204137-stats-list/ Share on other sites More sharing options...
Pikachu2000 Posted June 7, 2010 Share Posted June 7, 2010 Here's what I get at that URL: Not Found The requested URL /stats/2010/thrsou.php was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Link to comment https://forums.phpfreaks.com/topic/204137-stats-list/#findComment-1069196 Share on other sites More sharing options...
netman182 Posted June 7, 2010 Author Share Posted June 7, 2010 Fixed the link. Link to comment https://forums.phpfreaks.com/topic/204137-stats-list/#findComment-1069200 Share on other sites More sharing options...
Pikachu2000 Posted June 7, 2010 Share Posted June 7, 2010 What is the data type for that field? Is it integer type? Link to comment https://forums.phpfreaks.com/topic/204137-stats-list/#findComment-1069202 Share on other sites More sharing options...
netman182 Posted June 7, 2010 Author Share Posted June 7, 2010 varchar... should i change it? Link to comment https://forums.phpfreaks.com/topic/204137-stats-list/#findComment-1069204 Share on other sites More sharing options...
marcus Posted June 7, 2010 Share Posted June 7, 2010 try $result = mysql_query("SELECT * FROM players WHERE division='thrsou' AND point >= '1' ORDER BY CAST(point AS UNSIGNED) DESC "); Link to comment https://forums.phpfreaks.com/topic/204137-stats-list/#findComment-1069205 Share on other sites More sharing options...
netman182 Posted June 7, 2010 Author Share Posted June 7, 2010 Thank you! i knew it was something dumb like that. it always is. Link to comment https://forums.phpfreaks.com/topic/204137-stats-list/#findComment-1069208 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.