Cascading menu

<?php
    header("content:text/html;charset=utf8");
    $con=@mysql_connect("localhost","root","");
    mysql_select_db("hnthdl",$con);
    mysql_query("set name utf8");
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<script>
    function selectcity(x){
        if(x!="Please choose"){
            window.location.href='test.php?pid='+x;
        }
    }
    function selecttown(x){
        if(x!="Please choose"){
            window.location.href='test.php?cid='+x+"&pid="+form1.hnthdl_area.value;
        }
    }
</script>
<body>
    <?php
        session_start();
        if($_GET[pid]!=""){ $_SESSION["pid"]=$_GET[pid]; }
        if($_GET[cid]!=""){ $_SESSION["cid"]=$_GET[cid]; }
     ?>
<form  name="form1">
  <table width="300" border="0"   cellpadding="0"   cellspacing="0">   
      <tr   align="center">
        <td height="30" colspan="2" nowrap><span class="STYLE2">Application of cascading menu</span></td>
      </tr>
      <tr   align="center">
        <td width="120"   height="23"   nowrap><span class="STYLE1">省级名称:   </span></td>   
         <td width="180" align="left"   nowrap><select   name="hnthdl_area" onChange="selectcity(this.value);" >
           <option value="Please select"> Please select</option>   
         <?php
          $query=mysql_query("select * from hnthdl_area");
          $myrow=mysql_fetch_array($query);
          if($query==true){
            do{
        ?>
           <option value="<?php echo $myrow["id"];?>"
          <?php
            if($_SESSION["pid"]!="") {
            if($_SESSION["pid"]==$myrow[id]){
                 echo "selected=\"selected\"";
            }
        }?> ><?php echo $myrow[name];?></option>   
           <?php
          }while($myrow=mysql_fetch_array($query));
           }?>
         </select></td>
        </tr>
            <tr   align="center">
             <td   height="23"   nowrap class="STYLE1">市级名称:</td>
                <td align="left"   nowrap>
          <?php if($_GET[pid]!="") { ?>
        <select   name="hnthdl_area1" onChange="selecttown(this.value);">
            <option value="Please select" selected="selected"> Please select</option>             
          <?php $query=mysql_query("select * from hnthdl_area1 where pid='".$_GET[pid]."'");
                    if($query==true){
          while($myrow1=mysql_fetch_array($query)){                ?>
            <option   value="<?php echo $myrow1[id];?>"
          <?php
         if($_SESSION["cid"]!=""){
              if($_SESSION["cid"]==$myrow1[id]){
               echo "selected=\"selected\"";    
          }
           }?>><?php echo $myrow1[name1];?></option>
           <?php }}?>
          </select>
          <?php }  ?>  </td>
        </tr>
             <tr   align="center">
               <td height="23" nowrap class="STYLE1">County/town level name:</td>
               <td align="left"   nowrap>
        <?php if($_GET[cid]!=""){ ?>
        <select   name="hnthdl_area1">     
        <?php
        $query=mysql_query("select * from hnthdl_area2 where cid='".$_GET[cid]."'");
        if($query==true){
                     while($myrow1=mysql_fetch_array($query)){           ?>
           <option   value="<?php echo $myrow1[id];?>"><?php echo $myrow1[name2];?></option>
           <?php }}?>
        </select>
        <?php  } ?> </td>
            </tr>   
         </table>   
    </form>
</body>
</html>

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325283870&siteId=291194637