Je rencontre un problème avec un menu déroulant.
Je me suis aidé de la FAQ pour résoudre déjà diverses problèmes, mais il m'en reste un :
Si je mets entre double quote mon champ value je récupère bien ma chaine de caractère compléte même s'il y a des espaces, par contre je ne conserve pas l'item sélectionné.
Si je ne mets pas entre double quote mon champ value la chaine de caractère compléte récupérée s'arrête au 1er espace, par contre je conserve l'item sélectionné.
Ci-joint le bout de code incriminé :
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 <td align="left"><div align="center"> <select name="family" style="width:120;font-size:11" onclick="submit()"> <?php mysql_select_db('cde_access',$db); $sqlf = "select distinct product_fam from products"; $reqf = mysql_query($sqlf) or die('Erreur SQL !<br>'.$sqlf.'<br>'.mysql_error()); while($products = mysql_fetch_array($reqf)){ if(isset($_POST['family'])and $_POST['family'] == $products['product_fam']) $selected = "selected"; else $selected = ""; echo '<option value="'.$products['product_fam'].' '. $selected .'">'.$products['product_fam'];'</option>'; }?> </select> </div></td> <td align="left"><div align="center"> <?php if(isset($_POST['family']) > 0) { echo '<select name="brand" style="width:210;font-size:11" onclick="submit()">'; $sqlb = "select distinct product_brand from products where product_fam like '". $_POST['family'] ."'"; $reqb = mysql_query($sqlb) or die('Erreur SQL !<br>'.$sqlb.'<br>'.mysql_error()); while($products = mysql_fetch_array($reqb)){ if(isset($_POST['brand'])and $_POST['brand'] == $products['product_brand']) $selected = "selected"; else $selected = ""; echo '<option value="'.htmlentities($products['product_brand']).' '. $selected .'">'.$products['product_brand'];'</option>'; } }?></select> </div></td> <td align="left"><div align="center"> <?php if(isset($_POST['brand']) > 0 && isset($_POST['family']) > 0) { echo '<select name="ss_fam" style="width:210;font-size:11" onclick="submit()">'; $sqlc = "select distinct product_ss_fam from products where product_fam like '". $_POST['family'] ."' and product_brand like '". $_POST['brand'] ."'"; $reqc = mysql_query($sqlc) or die('Erreur SQL !<br>'.$sqlc.'<br>'.mysql_error()); while($products = mysql_fetch_array($reqc)){ if(isset($_POST['ss_fam'])and $_POST['ss_fam'] == $products['product_ss_fam']) $selected = "selected"; else $selected = ""; echo '<option value="'.$products['product_ss_fam'].' '. $selected .'">'.$products['product_ss_fam'];'</option>'; } }?></select> </div></td> <td align="left"><div align="center"> <?php if(isset($_POST['ss_fam']) > 0 && isset($_POST['brand']) > 0 && isset($_POST['family']) > 0) { echo '<select name="segment" style="width:230;font-size:11" onclick="submit()">'; $sqls = "select distinct product_segment from products where product_fam like '". $_POST['family'] ."' and product_brand like '". $_POST['brand'] ."' and product_ss_fam like '". $_POST['ss_fam'] ."'"; $reqs = mysql_query($sqls) or die('Erreur SQL !<br>'.$sqls.'<br>'.mysql_error()); while($products = mysql_fetch_array($reqs)){ if(isset($_POST['segment'])and $_POST['segment'] == $products['segment']) $selected = "selected"; else $selected = ""; echo '<option value="'.$products['product_segment'].' '. $selected .'">'.$products['product_segment'];'</option>'; } }?> </select> </div></td>
Partager