je voudrais modifier ma table, articles, elle est composée de plusieurs champs dont un avec une image.
le code du formulaire:
et le code php:
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 <form action="modifierarticles.php" method="post" enctype="multipart/form-data" name="form1"> <table width="650" border="1" cellpadding="0" cellspacing="0" bordercolor="#CC9933"> <tr> <td><div align="center"> <table width="650" border="0" cellspacing="0" cellpadding="5"> <tr> <td width="339"><div align="right"></div></td> <td width="311"><div align="left"> </div></td> <td width="311" rowspan="7"><img name="photo" src="../images/<?php echo $row_rsRecupArticle['photo']; ?>" alt=""></td> </tr> <tr> <td><div align="right">Titre : </div></td> <td><div align="left"> <input name="titre" type="text" id="titre" value="<?php echo $row_rsRecupArticle['titre']; ?>"> </div></td> </tr> <tr> <td><div align="right"></div></td> <td><div align="left"> </div></td> </tr> <tr> <td><div align="right">Description : </div></td> <td><div align="left"> <textarea name="description" cols="40" id="description"><?php echo $row_rsRecupArticle['description']; ?></textarea> </div></td> </tr> <tr> <td><div align="right">Prix : </div></td> <td><div align="left"> <input name="prix" type="text" id="prix" value="<?php echo $row_rsRecupArticle['prix']; ?>" size="10"> </div></td> </tr> <tr> <td><div align="right">Sous menu : </div></td> <td><div align="left"> <select name="ref_menu" id="ref_menu" title="<?php echo $row_rsRecupArticle['ref_menu']; ?>"> <?php do { ?> <option value="<?php echo $row_rsSelectTheme['id_menu']?>"><?php echo $row_rsSelectTheme['item_menu']?></option> <?php } while ($row_rsSelectTheme = mysql_fetch_assoc($rsSelectTheme)); $rows = mysql_num_rows($rsSelectTheme); if($rows > 0) { mysql_data_seek($rsSelectTheme, 0); $row_rsSelectTheme = mysql_fetch_assoc($rsSelectTheme); } ?> </select> </div></td> </tr> <tr> <td><div align="right">Photo : </div></td> <td><div align="left"> <input type="hidden" name="MAX_FILE_SIZE" value="100000"> <input name="photo" type="file" id="photo"> </div></td> </tr> <tr> <td colspan="3"><div align="right"></div> <div align="center"> <input type="submit" name="Submit" value="MODIFIER"> <input name="modifArticle" type="hidden" id="modifArticle" value="ok"> </div></td> </tr> </table> </div></td> </tr> </table> </form>
je n'ai aucune erreur , mais la modification ne se réalise pas, rien ne se passe. Avez-vous une idée pour remédier à cette situation , Merci
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 //init des variables <?php if(!isset($_POST['titre'])) $titre=""; else $titre=$_POST['titre']; if(!isset($_POST['description'])) $description=""; else $description=$_POST['description']; if(!isset($_POST['prix'])) $prix=""; else $prix=$_POST['prix']; if(!isset($_POST['ref_menu'])) $ref_menu=""; else $ref_menu=$_POST['ref_menu']; if(!isset($_POST['modifArticle'])) $modifArticle="non"; else $modifArticle=$_POST['modifArticle']; if(!isset($_FILES['photo'])) $photo['photo']=array('name'=>'','size'=>0); else $photo['photo']=$_FILES['photo']; //---------------------------- ?> <?php $colname_rsRecupArticle = "-1"; if (isset($_GET['reference'])) { $colname_rsRecupArticle = $_GET['reference']; } mysql_select_db($database_dream, $dream); $query_rsRecupArticle = sprintf("SELECT * FROM articles WHERE reference = %s", GetSQLValueString($colname_rsRecupArticle, "int")); $rsRecupArticle = mysql_query($query_rsRecupArticle, $dream) or die(mysql_error()); $row_rsRecupArticle = mysql_fetch_assoc($rsRecupArticle); $totalRows_rsRecupArticle = mysql_num_rows($rsRecupArticle); mysql_select_db($database_dream, $dream); $query_rsSelectTheme = "SELECT * FROM menu ORDER BY id_menu ASC"; $rsSelectTheme = mysql_query($query_rsSelectTheme, $dream) or die(mysql_error()); $row_rsSelectTheme = mysql_fetch_assoc($rsSelectTheme); $totalRows_rsSelectTheme = mysql_num_rows($rsSelectTheme); ?> <?php if ($modifArticle=="ok") { //---Mise à jour dans la base mysql_select_db($database_dream, $dream); $updateArticles = "UPDATE articles SET titre='$titre', description='$description', prix='$prix', ref_menu='$ref_menu' "; if ($photo['photo']['size']!=0) {$photo_name=$_FILES['photo']['name']; $updateArticles .= ", photo='$photo_name'";} $updateArticles .= "WHERE reference='$reference' "; mysql_query($updateArticles, $dream) or die(mysql_error()); //----Gestion de la photo de l'article si elle a était modifiée if ($photo['photo']['size']!=0 ) { $repertoire="../photos/"; move_uploaded_file($photo['photo']['tmp_name'],$repertoire.$photo['photo']['name']); } //----Redirection vers l'écran de Gestion des articles header("Location: valider.php"); } ?>
Partager