我已经使用 php 和 mysql 创建了一个网页,代码工作正常,但问题是我包含了这么多提交按钮,因此我的网页被重绘了很多次。我失去了一些价值,即 $emirate 价值和 $areas 价值。我使用变量 $choice 来存储这些值,但由于页面正在重绘,我没有得到这些值。请帮帮我。
$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>";
我怎样才能保留它们?