Hello,
I’m having some problems with an array I’ve made:
[code=php]
<?
$coptions = array();
$coptions[] = “Any”;
$coptions[] = “Flat/apartment”;
$coptions[] = “House”;
$coptions[] = “Bungalow”;
$coptions[] = “Villa”;
$coptions[] = “Semi-Detached”;
$coptions[] = “Detached”;
$coptions[] = “Other”;
echo ‘<select name=”property_type” id=”property_type” style=”width:115px”>’;
foreach ($coptions as $key => $val) {
echo “<option” . ($val == $_SESSION[‘property_type’] ? ” selected” : “”) . “>$val</option>”;
}
echo “</select>”;
?>
Basically when submitted I wish to store the index value of the array in the session(rather than the name value which it is just now).
So if other’ was selected and submitted, then the HTML echo’d out would be:
[code=html]<option value=”1″ selected>Flat/apartment</option>
I’m sure it’s something simple needing changed, thanks for your help.