Bonjour,
j affiche mes tables et champ sous forme de tableau en php j ai a cote de chaque ligne indiquer une option modifier qui me renvoie sur une autre page la ligne selectionné et que je peux modifie r...
je veux modifier mon id, reference, artiste, album, format quand je fais mon update tout va bien sauf qu il met a jour mon champ id (auto increment) a zero alors qu il etait a 1, 2, 3 ... comment modifier pour le champ id reste le meme ?
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Catalogue</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body link="#000000" vlink="#444444" alink="#888888"> <div id="body"> <?php include ('config.php'); include ('connexion.php'); $id = $_GET["id"]; $sql = "SELECT id, reference, artiste, album, format FROM contenu WHERE id='".$_GET ['id']."'" ; $req = mysql_query($sql) or die( mysql_error() ) ; $total = mysql_num_rows($req); echo $sql2= "UPDATE contenu SET id='".$_POST['id']."', reference='".$_POST ['reference']."', artiste='".$_POST['artiste']."',album='".$_POST ['album']."',format='".$_POST['format']."' WHERE id ='".$_GET['id']."'" ; $req2= mysql_query($sql2) or die('Erreur SQL !'.$sql2.'<br>'.mysql_error()); { echo '<form method ="post" action="modifier.php">'; echo '<table>'."\n"; echo '<tr>'; echo '<td ><b><u>id</u></b></td>'; echo '<td ><b><u>reference</u></b></td>'; echo '<td><b><u>artiste</u></b></td>'; echo '<td><b><u>album</u></b></td>'; echo '<td><b><u>format</u></b></td>'; echo '</tr>'."\n"; while($row = mysql_fetch_array($req)) { echo '<tr>'; echo '<td>'.$id.'</td>'; echo '<td><input type="text" name="reference" value="'.$row ["reference"].'"/></td>'; echo '<td><input type="text" name="artiste" value="'.$row["artiste"].'"/></td>'; echo '<td><input type="text" name="album" value="'.$row["album"].'"/></td>'; echo '<td><input type="text" name="format" value="'.$row["format"].'"/></td>'; echo '</tr>'."\n"; } echo '</table>'."\n"; echo '<input type="submit" name="btOk" value="Modifier"/>'; echo '</form>'; if (isset($_POST['btOk'])) { if($req2) { echo ("L'insertion a été correctement effectuée") ; echo '<br><a href="http://arm- info.hd.free.fr/label_modif.php">Retour sur les labels</a></br>'; } else { echo("L'insertion à échouée") ; } } } ?> </body></html> <?php mysql_close(); ?>
Partager