I want to keep what the user selected so when he clicks back and goes to my search the values are still there, have three listboxes. Country, State, City
Country Listbox
<select name="country" id="country" onChange="filter_state();">
<?php
echo "<option selected>" . $_POST['country']; "</option>";
$sql = "SELECT * FROM tbl_country";
$result = mysql_query($sql);
$i=0;
while($row = mysql_fetch_assoc($result)){
if($i <= 0){
$country = $row["id"];
}
echo "<option value='".$row['id']."'>".$row['fld_country']."</option>";
$i++;
}
?>
</select>
State Listbox
<select name="state" id="state" onChange="filter_city();">
<?php
echo "<option selected>" . $_GET['state']; "</option>";
$sql = "SELECT * FROM tbl_state where fld_country=$country";
$result = mysql_query($sql);
$j=0;
while($row = mysql_fetch_assoc($result)){
if($j <= 0){
$state = $row["id"];
}
echo "<option value='".$row['id']."'>".$row['fld_state']."</option>";
$j++;
}
?>
</select>
City listbox
<select name="city" id="city">
<?php
//echo "<option selected>" . $_GET['city']"</option>";
$sql = "SELECT * FROM tbl_city where fld_countryid=$country AND fld_stateid=$state";
$result = mysql_query($sql);
while($row = mysql_fetch_assoc($result)){
echo "<option value='".$row['id']."'>".$row['fld_city']."</option>";
$i++;
}
?>
</select>
The line
echo "<option selected>" . $_GET['state']; "</option>";
is what i want to try use, but it leaves it empty each time