I create this code to display a list of countries, I would retrieve the selected country but it does not work
<?php
include 'includes/combo.php';
?>
<?php
echo "<label for='pays'>Pays*</label>
<select id='pays' name='pays '>";
while ($row = mysql_fetch_array($combo)) {
echo "<option>$row[0]</option>";
}
echo "</select> ";
echo "<option>$row[0]</option>";
?>
and recover with a
if(isset($_POST['pays']))
$pays=$_POST['pays'];
else
$pays="";
echo $pays;
but the pays value is not recouped
echo"<option value=" . $row[0] . ">$row[0]</option>";
To retrieve the value of your option
Try this
<?php
include 'includes/combo.php';
?>
<?php
echo '<label for="pays">Pays*</label>
<select id="pays" name="pays">';
while ($row = mysql_fetch_array($combo)) {
echo '<option value="' . $row[0] . '">' . $row[0] . '</option>';
}
echo '</select>';
?>
You have one space after name in select And your option hasn't value attribut