Jump to content

Create Ranking


Salem

Recommended Posts

 

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

Link to comment
Share on other sites

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++;
}

?>

 

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...