First, the form seems to be submitting as soon as I enter the fifth value in postcode? Not sure you want this behavior, but maybe you do, but it feels a little out of control to the user.
I think I would test when you are writing the <option> tags for the drop down if the item has been selected (submitted) before and do something like this...
<?php
@suburb = $_POST['suburb'];
... more code goes here ...
while($pop = mysql_fetch_array($query)) {
$selected = ( $pop['postcode'] == $suburb ) ? ' selected' : '';
echo "<option value=\"$suburb\"$selected>$pop[suburb]</option>";
}
?>
Shouldn't you be using POST methods for form submission? Why try and use both?
Why are you using the
$suburb value for all of your option values?
Anyway, what I've got here is a quick test to see if the previously posted value is the same as the value you are writing to the current drop down option -- if it is it populates
$selected with the string
' selected', and if not it populates it with an empty string
''
I don't know for certain -- looking at your page code -- that
$pop['postcode'] is the correct value to compare to the option values, but something will be and then this should work.
Good luck