Bonjour,

SVP je voudrais faire un bouton de modifier dans un tableau qui récupère les donnees de la BD mais j'arrive pas à modifier que le dernier enregistrement récupéré de la table.

Prière de m'aider .
Code : 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
66
67
68
69
70
71
72
73
74
75
76
 
 
<?php include ('../modeles/pdo.php');?>
 
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
 
</head>
 
<body>
<div id="table">
  <table id="tab" border="1px" bordercolor="#666666">
 <th>ID</th> <th>TITRE</th> <th>EDITER</th>  <th>SUPPRIMER</th>
 
 
 <?php
 
    $tab = array();
        /* -----------Modification des enregistrements---------------- */
   if(isset($_REQUEST['modifier']))
 
     {
       $id=$_REQUEST['id_domaine'];
 
       $label_domaine=$_REQUEST['label_domaine'];
 
$requete=$bdd->exec("update domaines set label_domaine ='".$label_domaine."' WHERE id_domaine =".$id."");
if($requete)
  {
    echo("La modification à été correctement effectuée") ;
  }
  else
  {
   // echo("La modification à échouée") ;
  }
 
   $bdd->query('SELECT * FROM domaines');
 
      }
 
 
  /* -----------Affichage des enregistrements---------------- */
 
          $rep = $bdd->query('SELECT * FROM domaines');
 
                  while ( $d = $rep->fetch())
                            {
 
 
   ?>  
   <form action=<?php echo $_SERVER['PHP_SELF'];?> method="post">
 
  <?php   echo "<tr>";
 
   echo "<td><input  type='hidden' name='id_domaine'  value=" . $d['id_domaine'] . " />". $d['id_domaine']."</td>";
   echo "<td><input type='text'   name='label_domaine' style='width:250px;' value='" . $d['label_domaine'] . "'/></td>";
 
   echo "<td><input class='mod' type='submit' value='' name='modifier'/> </td>";
   echo "<td><input type='submit' class='supp' value='' name='supprimer'  /></td>";
 
   echo"</tr>";
 
    }
 
 
   ?>
 
 </form>
 
 
 </table>
 
 
 
 
</body>
</html>