Retain dynamic drop down value from php array after submit
<p>I have got a dropdown list being dynamically populated from an array but I can't seem to get the syntax correct so that it displays the selected value after the form is submitted.</p>

<p>This is what I have so far..</p>

<pre><code>&lt;select id="country" name="country"&gt;
    &lt;option value=""&gt;Please Select&lt;/option&gt;
&lt;?php
foreach ($countrylist as $value =&gt; $country) {
    echo '&lt;option value="' . $value . '" ' . ($selected == $value ? ' selected' : '') . '&gt;' . $country . '&lt;/option&gt;';
} ?&gt;

&lt;/select&gt; 
</code></pre>

<p>It seems that somewhere along the line I have made a mistake but I can't seem to work out where.</p>

<p>Thanks is advance</p>
