Eléphanteau du PHP |
12 Messages
07 déc. 2012, 14:53
Dans la page précédente j'affiche un tableau et lorsque je clique sur un nom je veux afficher les informations spécifiques à la personne contenues dans la base de données.
Page précédente :
$sql = "SELECT identifiant ,nom,prenom,civilite,fonction,unite,unite2,batiment,batiment2,pole,pole2 FROM personnel ORDER BY nom" ;
// on envoie la requête
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$num_rows = mysql_num_rows($req);
if ($num_rows != 0 ){
echo "<table border='1'>
<thead>
<th>Nom</th>
<th>Prénom</th>
<th>civilite</th>
<th>Fonction</th>
<th>Unité</th>
<th>Unité</th>
<th>Batiment</th>
<th>Batiment</th>
<th>Pôle</th>
<th>Pôle</th>
</thead>";
while($row = mysql_fetch_array($req)) {
echo "<tr>";
echo '<td><a id ="lien_nom" href="personnel.php?username='.$row['identifiant'].'">'. $row['nom'].'</a></td>';
echo "<td>". $row['prenom'] . "</td>";
echo "<td>" . $row['civilite'] . "</td>";
echo "<td width=15%>" . $row['fonction'] . "</td>";
echo "<td>" . $row['unite'] . "</td>";
echo "<td>" . $row['unite2'] . "</td>";
echo "<td>" . $row['batiment'] . "</td>";
echo "<td>" . $row['batiment2'] . "</td>";
echo "<td>" . $row['pole'] . "</td>";
echo "<td>" . $row['pole2'] . "</td>";
echo "</tr>";
}
echo "</table>";}
Page suivante :
$id_pers = $_GET['username'];
$link = mysql_connect('sql.franceserv.fr', 'xxx', 'www');
mysql_select_db('xxx', $link);
// on crée la requête SQL
//$sql = 'SELECT identifiant,nom,prenom,civilite,fonction,unite,unite2,batiment,batiment2,pole,pole2 FROM personnel WHERE identifiant=$id_pers' ;
// on envoie la requête
$reqmail = "SELECT * FROM personnel WHERE identifiant = '" .$id_pers. "'";
$req = mysql_query($reqmail,$db) or die('Erreur SQL2 !<br>'.$reqmail.'<br>'.mysql_error());