keep selected dynamic dropdown list after submit
<p>Below is my code to populate a dynamic list.</p>

<pre><code>&lt;?php
if(isSet($_POST['supplier'])) {

include 'db.php';

$stmt = $mysql-&gt;prepare("SELECT DISTINCT SupplierBrand FROM plastic WHERE HeadingNo='".$_POST['supplier']."' ORDER BY SupplierBrand");
$stmt-&gt;execute();
$stmt-&gt;bind_result($supplierBrand);
?&gt;
&lt;option value="All" width="100px"&gt;--ALL--&lt;/option&gt;
&lt;?php
while ($row = $stmt-&gt;fetch()) : ?&gt;

&lt;option value="&lt;?php echo $supplierBrand; if($_POST['county'] == $supplierBrand) {echo "selected";} ?&gt;" width="100px"&gt;&lt;?php echo $supplierBrand; ?&gt;&lt;/option&gt;

&lt;?php endwhile; ?&gt;

&lt;?php } ?&gt;
</code></pre>

<p>I added the code 
<code>if($_POST['county'] == $supplierBrand) {echo "selected";}</code> 
to try and retain my selected value onSubmit. This code in this context does not work. After debugging I noticed that the county value is undefined. 
This is error from chrome debugging:</p>

<pre><code>Notice&amp;lt;/b&amp;gt;:  Undefined index: county
</code></pre>

<p>How to get the value county for which its on another page and further more the above php script value <code>$_POST['supplier']</code> is passed by use of jquery. </p>

<p>Below is the html code:</p>

<pre><code>&lt;div id="county_drop_down"&gt;
                        &lt;select id="county" name="county" &gt;
                            &lt;option value="" width="100px"&gt;Supplier...&lt;/option&gt;
                        &lt;/select&gt;
                        &lt;/div&gt;
                            &lt;span id="loading_county_drop_down"&gt;
                            &lt;img src="css/loader.gif" width="16" height="16" align="absmiddle"&gt;&amp;nbsp;Loading...&lt;/span&gt;
                            &lt;div id="no_county_drop_down"&gt;No lens type/design has been selected.&lt;/div&gt;
</code></pre>

<p>For the javascript, please see this <a href="http://stackoverflow.com/questions/16056702/how-to-debug-using-firebug-and-show-the-value-of-radio-button/16057150?noredirect=1#16057150">link</a></p>
