Salem Posted May 25, 2018 Report Share Posted May 25, 2018 Hello everyone, I would like to create a ranking of pilots according to the pay, but unfortunately, I have a problem of coding. If anyone would have an idea about the solution it would be cool. I want to use the $pilots table and collect the id and totalpay Here is my code and my bug below. <?php mysql_select_db("pilots"); $reponse = mysql_query('SELECT * FROM pilotid ORDER BY totalpay'); $rang = 0; while ($pilots = mysql_fetch_array($reponse)) { $rang++; echo $rang; echo $pilots['pilotid']; echo $pilots['totalpay']; } ?> Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/dahvirtumu/smart/core/templates/toppilot/tp_index.php on line 4 Warning: mysql_connect(): Unknown MySQL server host 'dahvirtumub738' (1) in /home/dahvirtumu/smart/core/templates/toppilot/tp_index.php on line 4 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/dahvirtumu/smart/core/templates/toppilot/tp_index.php on line 13 Thank's for your help Regards Quote Link to comment Share on other sites More sharing options...
web541 Posted May 25, 2018 Report Share Posted May 25, 2018 Try this <?php $pilots = DB::get_results("SELECT * FROM ".TABLE_PREFIX."pilots ORDER BY `totalpay` DESC"); $ranking = 0; foreach($pilots as $p) { echo '#'.$ranking.' | '.PilotData::getPilotCode($p->code, $p->pilotid).' - $'.$p->totalpay; echo '<br />'; $ranking++; } ?> 1 Quote Link to comment Share on other sites More sharing options...
Salem Posted May 26, 2018 Author Report Share Posted May 26, 2018 Hello web541, It works perfectly, thank you for your help. Have a nice week end Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.