Create Ranking

 

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

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 Like

 

Hello web541,

It works perfectly, thank you for your help.

Have a nice week end