Bon while mais mauvais nom de categories!
Je vient de finir se code qui me crée un sélect selon le contenue de ma BdD le problème que j'ai est que je reçoit le mauvais $catName dans mon echo et je ne sais pas pourquoi. pourriez vous me filer un coup de main merci.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
<?php
$sql1 = "SELECT * from categories ORDER BY catID";
$query1 = mysql_query($sql1,$connect);
$sql2 = "SELECT * from subCat";
$query2 = mysql_query($sql2,$connect);
?>
<select name="selectCat">
<option value="-1">Choisissez un Catégorie</option>
<?php
while($cat = mysql_fetch_array($query1)){
$catName = $cat[1];
while($subCat = mysql_fetch_array($query2)){
$subCatID = $subCat[0];
$catID = $subCat[1];
$subCatName = $subCat[2];
echo "<option value=\"$catID.$subCatID\">$catName / $subCatName</option>";
}
}
?>
</select>
<?php mysql_close(); ?> |
voila le resultat et voila ce que je devrais avoir
--- Résulta Actuel ---
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
<select name="selectCat">
<option value="-1">Select a category</option>
<option value="1.1">links / Homepage</option>
<option value="2.1">links / General Information</option>
<option value="2.2">links / Restoration</option>
<option value="2.3">links / Volunteer/Staff</option>
<option value="3.1">links / Shield</option>
<option value="3.2">links / Fruits</option>
...
<option value="9.1">links / Representatives</option>
<option value="10.1">links / Links</option>
</select> |
--- Résulta Souhaiter ---
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
<select name="selectCat">
<option value="-1">Select a category</option>
<option value="1.1">Home / Homepage</option>
<option value="2.1">Apropot / General Information</option>
<option value="2.2">Apropot / Restoration</option>
<option value="2.3">Apropot / Volunteer/Staff</option>
<option value="3.1">Publication / Shield</option>
<option value="3.2">Publication / Fruits</option>
...
<option value="9.1">Autre / Representatives</option>
<option value="10.1">links / Links</option>
</select> |
ce qui donne:
Code:
1 2
|
<option value=$catID.$subCatID>$catName / $subCatName</option> |