I have a user system and points for each user and i want to make a script that gets the top 10 richest people from the database.
Could any one help me?
Could any one help me?
| DanielXP wrote: |
| I have a user system and points for each user and i want to make a script that gets the top 10 richest people from the database.
Could any one help me? |
| Code: |
| <?php
$con = mysql_connect(<DBHOST>, <DBUSER>, <DBPASS>); if (!mysql_select_db(<DBNAME>)) { exit('Database unavailable: ' . mysql_error()); } $sql = "SELECT <name> FROM <table> ORDER BY <wealth> DESC LIMIT 10"; $res = mysql_query($sql) or die('Error in query: ' . mysql_error()); while ($row = mysql_fetch_row($res)) { echo $row[0], "<br>\n"; } mysql_free_result($res); mysql_close($con); // ... |
| DanielXP wrote: |
| Where will that find out who has the biggest number? |
| DanielXP wrote: |
| in users where the username and points is the db info |
| vignesh_natraj wrote: |
| jus get that variable and compare the values using arrays and then sort accordingly it is usually done that way |