Bonjour à nouveau,

Je reviens vers vous pour mon formulaire avec listes déroulantes.
Je prépare une petite console d'administration pour pouvoir modifier des vignettes promo sur un site.
Tous mes champs s'affichent avec le contenu stocké dans la base de données, mais ce n'est pas le cas pour la liste déroulante.
Je n'ai pas trouvé la solution. Est-ce que vous pouvez m'aider ?
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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
 
<?php
 
define('ROOT','../');
$dossierImages = ROOT.'img/images-slider/';
 
require(ROOT.'config/config.php');
require('SBImage.php');
 
$emplacement = $_POST["emplacement"];
//$_SESSION['emplacement'] = $_POST['emplacement'] 
 
 
function verifieTypeMime($type){
			$typesacceptes = array('image/jpeg','image/jpg','image/png','image/gif','image/pjpeg');  
			if(in_array($type,$typesacceptes)) return true;
				else return false;
}
 
 
$connect = mysql_connect(MYHOST, MYUSER, MYPASS)  or die ('Identifiants incorrects');  
mysql_select_db(MYDB) or die ('Base de données incorrecte');  
 
 
 
if(isset($_POST) && !empty($_POST)){
 
	if(
		!empty($_POST['slide'])&&
		!empty($_POST['titre'])&&
		!empty($_POST['lien'])&&
		!empty($_POST['description'])&&
		!empty($_POST['emplacement'])){
 
		$import = false;	
		if(isset($_FILES['image'])){		
			if(verifieTypeMime($_FILES['image']['type'])){
				$import = true;
				$fichier = $dossierImages.$_FILES['image']['name'];
				copy($_FILES['image']['tmp_name'],$fichier);
				SBImage::resize($fichier,210,160,true);
 
			}
		}
		$requete = '';
		$reqFile = '';
		if($_POST['modif'] == "true"){
			if($import)
				$reqFile = ",img='".$_FILES["image"]["name"]."'";
				$requete .= "UPDATE slider SET 
				titre='".$_POST['titre']."',
				lien='".$_POST['lien']."',
				texte='".$_POST['description']."',
				emplacement='".$_POST['emplacement']."'".$reqFile." 
				WHERE id='".$_POST['slide']."'";
				}else{
			if($import)
				$reqFile = $_FILES["image"]["name"];
			$requete = "INSERT INTO slider(id,titre,lien,texte,img,emplacement) 
					VALUES('".$_POST['slide']."',
							'".$_POST['titre']."',
							'".$_POST['lien']."',
							'".$_POST['description']."',
							'".$_POST['emplacement']."',
							'".$reqFile."'
							)";	
		}
		mysql_query($requete);
	}
}
mysql_close();
?>
 
 
 
 
 
 
<?php
echo '<select name="emplacement">';
for ($i = 0; $i <= 2; $i++) {
        echo "<option";
        if ( isset ($_POST['emplacement']) && $i == $_POST['emplacement'] ) {
                echo ' selected="selected"';
        }
        echo ">$i</option>\n";
}
echo "</select>";
?>
 
 
 
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Promos admin</title>
 
 
 
</head>	
	<body class="admin">
 
 
		<div id="pageContainer">
 
		<div id="CartoucheHaut">
 
		<table width="830" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td colspan="4">&nbsp;</td>
              </tr>
              <tr>
                <td height="43" colspan="4"> <div align="center">
 
                  <p style="font-family:Arial; text-shadow: 2px 2px 2px #fff; text-decoration: none; padding-top: 20px;font-size:20px;">Administration PROMOS</p>
                </div></td>
          </tr>
              <tr>
                <td colspan="4">&nbsp;</td>
              </tr>
              <tr>
                <td colspan="4"></td>
              </tr>
              <tr>
                <td width="9">&nbsp;</td>
                <td width="255"><a href="javascript:ajouteSlideVide()" class="button blue small3"  style="cursor:pointer;margin-left:10px">Ajouter une promo</a></td>
                <td width="691">&nbsp;</td>
                <td width="77">&nbsp;</td>
              </tr>
              <tr>
                <td colspan="4">&nbsp;</td>
              </tr>
              <tr>
                <td colspan="4">&nbsp;</td>
              </tr>
            </table>
 
 
		  </div>
 
 
 
 
			<div id="formulaires">
					<?php
					$connect = mysql_connect(MYHOST, MYUSER, MYPASS)  or die ('Identifiants incorrects');  
					mysql_select_db(MYDB) or die ('Base de données incorrecte');  
					$requete = "SELECT id,titre,lien,texte,img,emplacement FROM slider ORDER BY id";
					$result = mysql_query($requete);
					if(mysql_num_rows($result)){
						while($cur_item = mysql_fetch_assoc($result)){
							echo '<form method="post" enctype="multipart/form-data" style="display:block;float:left;width:270px;background-color: #E6EFF7;padding:10px">
									<fieldset style="border: 1px solid #73aad2;padding:7px;margin:3px;">
										<legend style="font-size:1.8em;display:block;margin-left:200px;position:absolute;">'.$cur_item['id'].'</legend>
										<input type="hidden" class="loginRemplissage" name="slide" id="idslide" value="'.$cur_item['id'].'" /><br />
										<input type="hidden" class="loginRemplissage" name="modif" id="modif" value="true" />
										
										<label for="titre" style="font-family: Arial, Helvetica, sans-serif;font-size: 12px;color: #3779AA;margin-left: 4px;font-weight: normal;
margin-bottom: 0px;margin-top: 0px;text-align: right;padding-right: 5px;display:block;
	float:left;vertical-align: middle;" >Titre</label><input type="text" size="30" class="loginRemplissage" name="titre" value="'.htmlspecialchars($cur_item['titre']).'"/><br />
										<label for="lien" style="font-family: Arial, Helvetica, sans-serif;font-size: 12px;color: #3779AA;margin-left: 4px;font-weight: normal;
margin-bottom: 0px;margin-top: 0px;text-align: right;padding: 0px;display:block;
	float:left;padding-right: 5px;" >Lien</label><input type="text" size="30" class="loginRemplissage" name="lien" value="'.htmlspecialchars($cur_item['lien']).'" /><br /><br />
										<label style="font-family: Arial, Helvetica, sans-serif;font-size: 12px;color: #3779AA;margin-left: 4px;font-weight: normal;
margin-bottom: 0px;margin-top: 0px;text-align: right;padding: 0px;display:block;
	float:left;padding-right: 5px;">Description</label><textarea style="float:left;width:230px;margin:3px;color:#555;height:100px;" name="description">'.htmlspecialchars($cur_item['texte']).'</textarea><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
										<label style="font-family: Arial, Helvetica, sans-serif;font-size: 12px;color: #3779AA;margin-left: 4px;font-weight: normal;
margin-bottom: 0px;margin-top: 0px;text-align: right;padding: 0px;display:block;
	float:left;padding-right: 5px;">Image</label><input type="file" style="float:left;width:230px;margin:3px;color:#555;" name="image" /><br /><br />
										<img class="miniature" src="'.htmlspecialchars($dossierImages.$cur_item['img']).'" alt="image du slide" />
										
										<br />
										<label for="emplacement" style="font-family: Arial, Helvetica, sans-serif;font-size: 12px;color: #3779AA;margin-left: 4px;font-weight: normal;
margin-bottom: 0px;margin-top: 0px;text-align: right;padding: 0px;display:block;
	float:left;">Emplacement :</label>
	

		<select name="emplacement">
	<option ';
if($emplacement == "Haut") echo 'selected="selected"'; 
echo 'value="Haut">Haut</option>
	<option ';
if($emplacement == "Bas") echo 'selected="selected"';
echo 'value="Bas">Bas</option>
	</select>
 
	
	<br /><br />

	


										
										
										
										<button type="submit" class="button blue small3"  style="cursor:pointer">Modifier</button>
										<a class="supprimer" href="javascript:void(0)">Supprimer</a>
										<a class="positionplus" href="javascript:void(0)" style="color: #3779AA;">+</a>
										<a class="positionmoins" href="javascript:void(0)" style="color: #3779AA;">-</a>
									</fieldset>
							</form>';	
						}
 
					} else{
						echo '<form method="post" enctype="multipart/form-data" class="formulaireSlide">
									<fieldset>
										<legend style="font-size:1.8em;display:block;margin-left:200px;position:absolute;">1</legend>
										<input type="hidden" name="slide" id="idslide" value="1" />
										<label style="font-family: Arial, Helvetica, sans-serif;font-size: 12px;color: #3779AA;margin-left: 4px;font-weight: normal;
margin-bottom: 0px;margin-top: 0px;text-align: right;padding: 0px;display:block;
	float:left;">Titre</label><input type="text" name="titre" value=""/>
										<label style="font-family: Arial, Helvetica, sans-serif;font-size: 12px;color: #3779AA;margin-left: 4px;font-weight: normal;
margin-bottom: 0px;margin-top: 0px;text-align: right;padding: 0px;display:block;
	float:left;">Lien</label><input type="text" name="lien" value="" /><br /><br />
										<label style="font-family: Arial, Helvetica, sans-serif;font-size: 12px;color: #3779AA;margin-left: 4px;font-weight: normal;
margin-bottom: 0px;margin-top: 0px;text-align: right;padding: 0px;display:block;
	float:left;">Description</label><textarea name="description" style="float:left;width:180px;margin:3px;color:#555;height:100px;"></textarea>
										<label style="font-family: Arial, Helvetica, sans-serif;font-size: 12px;color: #3779AA;margin-left: 4px;font-weight: normal;
margin-bottom: 0px;margin-top: 0px;text-align: right;padding: 0px;display:block;
	float:left;">Image</label><input type="file" name="image" />
	<br />
	
	<label for="emplacement" style="font-family: Arial, Helvetica, sans-serif;font-size: 12px;color: #3779AA;margin-left: 4px;font-weight: normal;
margin-bottom: 0px;margin-top: 0px;text-align: right;padding: 0px;display:block;
	float:left;">Emplacement :</label>
	
	
	<select name="emplacement">
	<option ';
if($emplacement == "Haut") echo '"selected"'; 
echo 'value="Haut">Haut</option>
	<option ';
if($emplacement == "Bas") echo '"selected"';
echo 'value="Bas">Bas</option>
	</select>
	
		
	<br /><br />
	
	
	
	
	
										<button type="submit" class="button blue small3"  style="cursor:pointer">Ajouter</button>
										<a class="supprimer" href="javascript:void(0)">Supprimer</a>
										<a class="positionplus" href="javascript:void(0)" style="font-family: Arial, Helvetica, sans-serif;font-size: 12px;color: #3779AA;margin-left: 4px;font-weight: normal;
margin-bottom: 0px;margin-top: 0px;text-align: right;padding: 0px;display:block;
	float:left;">+</a>
										<a class="positionmoins" href="javascript:void(0)" style="font-family: Arial, Helvetica, sans-serif;font-size: 12px;color: #3779AA;margin-left: 4px;font-weight: normal;
margin-bottom: 0px;margin-top: 0px;text-align: right;padding: 0px;display:block;
	float:left;">-</a>
									</fieldset>
							</form>';
					}
					mysql_close();
					?>
 
 
			</div>
		</div>
 
	</body>
</html>