Pb fonction tableau

dwieser Messages postés 235 Statut Membre -  
dwieser Messages postés 235 Statut Membre -
Bonjour,

je suis en train de faire un tableau
j'ai une erreur sur "function distance"
impossible de l'afficher correctement dans mon tableau
pourriez vous me modifier l'erreur
j'ai essayé le calcul function distance séparément de l'ensemble de mon code
il fonctionne
ce que je n'arrive pas à faire et je ne sais pas comment faire
c'est l'instaurer dans mon tableau
pour que sur chaques lignes de mon tableau j'obtiens le résultat de la formule

MERCI PAR AVANCE DE VOS REPONSES


<?php    
include"config.php";    
?>    
<html>    
<head>    
               <title>Liste des joueurs</title>    
      
</head>    
<body>    
<center>    
<img src="images/war_city.gif" alt="warcity" width="400" height="200" />     
</center>    

Bonjour<?php if(isset($_SESSION['username'])){echo ' '.htmlentities($_SESSION['username'], ENT_QUOTES, 'UTF-8');} ?>,<br />    
Bienvenue sur notre site.<br />    
<center>    
  <h1>Liste des joueurs</h1><BR>    
      
</center><br/>    

<?php    
 if(isset($_SESSION['username']))    
{    
?>    

        
     <h2>Voici la liste des utilisateurs:</h2>    
<table>    
    <tr>    
     <th>Id</th>    
     <th>Nom d'utilisateur</th>    
     <th>Email</th>    
  <th>Nom Citée</th>    
  <th>Latitude</th>    
  <th>Longitude</th>    
  <th>Population</th>    
  <th>Distance</th>    
    </tr>    
     
     
     
<?php    


//On recupere les identifiants, les pseudos et les emails des utilisateurs    
$req = mysql_query('select id, username, email, nomVille, lat, lng, population from users');    


while($dnn = mysql_fetch_array($req))    
{    


$lat1 = 44.8569086;    
$lon1 =-0.6394692999999734;    
 $lat = $dnn['lat'];    
$lng = $dnn['lng'];    


function distance($lat1, $lon1, $lat, $lng) 
{    
 $lat1 = deg2rad($lat1);    
 $lat = deg2rad($lat);    
 $lon1 = deg2rad($lon1);    
 $lng = deg2rad($lng);    
     
 $R = 6371;    
 $dLat = $lat - $lat1;    
 $dLong = $lng - $lon1;    
 $var1= $dLong/2;    
 $var2= $dLat/2;    
 $a= pow(sin($dLat/2), 2) + cos($lat1) * cos($lat) * pow(sin($dLong/2), 2);    
 $c= 2 * atan2(sqrt($a),sqrt(1-$a));    
 $d= $R * $c;    
 return $d;    
 }    
?>    
 <tr>    
     <td class="left"><?php echo $dnn['id']; ?></td>    
     <td class="left"><a href="profile.php?id=<?php echo $dnn['id']; ?>"><?php echo htmlentities($dnn['username'], ENT_QUOTES, 'UTF-8'); ?></a></td>    
     <td class="left"><?php echo htmlentities($dnn['email'], ENT_QUOTES, 'UTF-8'); ?></td>    
  <td class="left"><?php echo htmlentities($dnn['nomVille'], ENT_QUOTES, 'UTF-8'); ?></td>    
  <td class="left"><?php echo htmlentities($dnn['lat'], ENT_QUOTES, 'UTF-8'); ?></td>    
  <td class="left"><?php echo $dnn['lng']; ?></td>    
  <td class="left"><?php echo $dnn['population']; ?></td>    


  <td class="left"><?php echo round (distance ($lat1, $lon1, $lat, $lng)) ;?></td>



  <td class="left"><a href="profile.php?id=<?php echo $dnn['id']; ?>"><form  name="attaque"><input type="button" value="attaquer"></form></td>    
  <td class="left"><a href="profile.php?id=<?php echo $dnn['id']; ?>"><form  name="écrire"><input type="button" value="lui écrire"></form></td>    
    </tr>    

<?php    
}    
?>    

</table>    
</br>    
 <?php    


 ?>    
    
     
<a href="index.php">Mon bureau</a><br />    
<a href="connexion.php">Se déconnecter</a>    
<?php    
}    
else    
{    
?>    
<a href="sign_up.php">Inscription</a><br />    
<a href="connexion.php">Se connecter</a>    
<?php    
}    
?>    
</body>    
</html>    






Moi je plante et toi tu creuses !!!
A voir également:

1 réponse

dwieser Messages postés 235 Statut Membre 9
 
bonjour,

je relance mon sujet

MERCI PAR AVANCE DE VOS REPONSES
0