Bonjour,

J'obtiens un tableau d'enregistrements (MySQL) en utilisant do{ }while() en PHP.

Je souhaite qu'un clic sur chacune des lignes ouvre une fiche individuelle.Par :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
$("tr").click(function(){$(location).attr('href',"reception.php?var=");});
j'obtiens bien la page d'affichage mais mes différents essais en JQUERY pour récupérer l'ID correspondant à chaque ligne restent vains.

Merci de l'éventuelle solution qui pourrait m'être proposée.

voir script complet ci-dessous :

Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php require_once('../Connections/GACR.php'); ?>
<?php
mysql_select_db($database_GACR, $GACR);
$query_r1 = "SELECT * FROM adherents WHERE adherents.R<>22 AND adherents.R<>23 ORDER BY adherents.nom";
$r1 = mysql_query($query_r1, $GACR) or die(mysql_error());
$row_r1 = mysql_fetch_assoc($r1);
$totalRows_r1 = mysql_num_rows($r1);
isset($startRow_r1)? $orderNum=$startRow_r1:$orderNum=0;
?>
<!doctype html>
<html>
<head>
<meta charset="iso-8859-1">
<title>LeTableau</title>
 
<style type="text/css">
 
</style>
 
<script type="text/javascript" src="jquery-1.7.js"></script>
<script type="text/javascript">
$(document).ready(function(){
 
 
  $("tr").mouseenter(function(){
$(this).css({"background-color":"#9cf"});
})
.mouseleave(function(){
$(this).css({"background-color":"#ffc"});
}); 
 
$("tr").click(function(){$(location).attr('href',"reception.php?var=<?php ?>");}); 
 
 });
 
</script>
 
</head>
 
<body>
<table id="tab1">
<tr>
  <th width="35" scope="col">N&deg;</th>
  <th width="70" scope="col">Id</th>
  <th width="168" scope="col">Nom Pr&eacute;nom</th>
  <th width="205" scope="col">Adresse</th>
  <th width="114" scope="col">CP</th>
  <th width="207" scope="col">Ville</th>
</tr>
<?php do { ?>
<tr>
  <td><?php echo ++$orderNum; ?></td>
  <td><?php echo $row_r1['id']; ?></td>
  <td align="left"><strong><?php echo $row_r1['nom']; ?></strong>&nbsp; <?php echo $row_r1['prenom']; ?></td>
  <td align="left"><?php echo $row_r1['adresse']; ?></td>
  <td><?php echo $row_r1['code_postal']; ?></td>
  <td align="left"><?php echo $row_r1['ville']; ?></td>
</tr>
<?php } while ($row_r1 = mysql_fetch_assoc($r1)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($r1);
?>