I have created a webpage using php and mysql, the code works fine except the problem is I have included so many submit buttons and hence my webpage gets redrawn many times. I lose some values i.e. $emirate value and $areas value. I used a variable $choice for storing those values but since the page is being redrawn, I don't get the values. Help me please.
$data = mysql_query("SELECT * FROM emirate")
or die(mysql_error());
$choice="";
Print "<table border cellpadding=3>";
print"<tr><th><form method=get action=''><select id=EMIRATE size=1 name='EMIRATE' class='comboBoo'>";
while($info = mysql_fetch_array( $data ))
{
Print "<option value=". $info['em_name'] .">".$info['em_name']."</option>";
}
print"</select><input type=submit value=OK></form></th>";
if(isset($_GET['EMIRATE'])){
$emirate=$_GET['EMIRATE'];
$choice.=$emirate;
$data = mysql_query("SELECT a_name FROM areas where em_id=(select em_id from emirate where em_name=\"".$emirate."\")")
or die(mysql_error());
Print "<th><form method=get action=''><select id='AREAS' name=AREAS size=1 class='comboBoo'><OPTION value=ALL>ALL</option><OPTION value=ALL>ALL</option>";
while($info = mysql_fetch_array( $data ))
{
Print "<option >".$info['a_name']."</option>";
}
print"</select><input type=submit value=OK></form></th>";
}
$choice.="->";
if(isset($_GET['AREAS'])){
$areas=$_GET['AREAS'];
$choice.=$areas;
$data = mysql_query("SELECT h_name FROM hypermarket_em where a_id=(select a_id from areas where a_name=\"".$areas."\")")
or die(mysql_error());
Print "<th><form method=get action=''><select name=HYPERMARKETS size=1 class='comboBoo'>";
while($info = mysql_fetch_array( $data ))
{
Print "<option>".$info['h_name']."</option>";
}
print"</select><input type=submit value=OK></form></th>";
}
Print "</tr></table>";
Print "<table border cellpadding=3><tr><th>".$choice."</th></tr></table>";
how can i retain them??