<html>
<title>HOMESITE Patrice DELPY - CHAMPIONNAT POWERBALL </title>
<body bgcolor="#FFFFFF">
<h1 align=center>CLASSEMENT</h1>
<p>&nbsp;</p>
<table width="80%" border="0">
  <tr>
    <td><img src="powerball.GIF" width="355" height="335"></td>
    <td><?       

// connexion avec la base
$db_type   = "mysql";
$db_user   = "analogde";
$db_pass   = "rainbow";
$db_name   = "analogde";
$db_host    = "sql2";


// authentification et connexion
  $connexion = mysql_connect($db_host,$db_user,$db_pass); 
  if(!$connexion)  
    { echo "D&eacute;sol&eacute;, y a un bl&eacute;me, connexion au serveur $db_host impossible\n";
      exit; 
    }

   // pointe sur la base
   $db = mysql_select_db($db_name,$connexion); 
   if(!$db)
      {  echo "D&eacute;sol&eacute; acc&eacute;s a la base $db_name impossible\n";
      }


switch($action)
{
		case 'g' :$result = MYSQL_QUERY("select * from powerball order by main_gauche desc");	break;
		case 'd' :$result = MYSQL_QUERY("select * from powerball order by main_droite desc");	break;
		case 'e' :$result = MYSQL_QUERY("select * from powerball order by endurance desc");	break;
		default  :$result = MYSQL_QUERY("select * from powerball order by main_droite desc");	
		
}		

/*if($action == 'g')
  { $result = MYSQL_QUERY("select * from powerball order by main_gauche desc");
    
  }	

if($action == 'd')
  { 
  	$result = MYSQL_QUERY("select * from powerball order by main_droite desc");
    
  }	

if($action == 'e')
  { $result = MYSQL_QUERY("select * from powerball order by endurance desc");
    
  }	

if ($action != 'g' || $action != 'd' || $action != 'e')
{
	 echo " classement de base";
	// recherche le nombre total d'entr&eacute;e dans la base
	$result = MYSQL_QUERY("select * from powerball order by main_gauche desc");
	
     }	*/
	
	
$number = MYSQL_NUM_ROWS($result);	

// affiche le nombre d'entr&eacute;e dans la base
echo "<p align=center>$number enregistrements.</p><br>";

$i=0;


// ent&ecirc;te du tableau
echo "<table border=1 align=center width='80%'><tr>
	
	<th>Ordre</th>
	<th>Nom</th>
	<th>Pr&eacute;nom</th>
		
	<th>
	<a href=\"powerball.php?action=g\">Gauche</a>
	</th>
	
	<th>
	<a href=\"powerball.php?action=d\">Droite</a>
	</th>
	
	<th>
	<a href=\"powerball.php?action=e\">Endurance</a>
	</th>
	
	<th colspan=2>Op&eacute;rations</th></tr>";

// mise en forme

$classement=0;

while ($i<$number) {
	
	$id=mysql_result($result,$i,"id");
	
	$nom=mysql_result($result,$i,"nom");  
	
	$prenom=mysql_result($result,$i,"prenom"); if ($prenom=="") {$prenom="-";}
	
	$gauche=mysql_result($result,$i,"main_gauche");
	if ($gauche=="") {$gauche="-";}

	$droite=mysql_result($result,$i,"main_droite");
	if ($droite=="") {$droite="-";}
	
	$endure=mysql_result($result,$i,"endurance");
	if ($endure=="") {$endure="-";}

$classement=$i+1;        
        
	// affichage des enregistrements
	echo "<tr> 
	<td align=center width='20'> <b>$classement</b> </td> 
	<td align=center width='150'> <b>$nom</b> </td> 
	<td align=center width='150'> $prenom </td>
	<td align=center width='150'> $gauche </td>
	<td align=center width='150'> $droite</td>
	<td align=center width='150'> $endure</td>
	<td><a href='modif.php?id=$id'>Modifier</a></td> 
	<td><a href='effacer.php?eff=$id'>Effacer</a></td></tr>";
	$i++;
	} 	
echo "</table>";

// menu de gestion
echo "<br><a href='ajout.php'><p align=center>Ajouter un enregistrement</p></a>";

// referme la connexion avec la base de donnée
mysql_close();
?></td>
  </tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</p>
</body>
</html>

