<?require('Include/conn.php');?>
.......
<tr><td>&nbsp;Country</td>
<td>  
<?php
   $result=mysql_query("select CouCd,CouName from country",$conn);
   while ($row=mysql_fetch_array($result)) {
   $CouCd=$row['CouCd'];
   $str.="<option value=$CityCd>".$row['CouName']."</option>";
   }
?>
      <select name="Country" style="width:220px "> 
      <?php
        echo "<option value=\"\">&nbsp;</option>".$str;
      ?>
     </select></td></tr>
<tr><td>&nbsp;State Code</td>
<td><?php
   $str = ""; //重置$str
   $sresult=mysql_query("select StateCd,StateName from state",$conn);
   while ($srow=mysql_fetch_array($sresult)) {
   $StateCd=$srow['StateCd'];
   $str.="<option value=$StateCd>".$srow['StateName']."</option>";
   }
?>
      <select name="StateCd" style="width:220px "> 
      <?php
        echo "<option value=\"\">&nbsp;</option>".$str;
      ?>
     </select></td></tr>

解决方案 »

  1.   


    <?require('Include/conn.php');?>
    .......
    <tr><td>&nbsp;Country</td>
    <td>  
    <?php
       $result=mysql_query("select CouCd,CouName from country",$conn);
       while ($row=mysql_fetch_array($result)) {
       $CouCd=$row['CouCd'];
       $str.="<option value=$CityCd>".$row['CouName']."</option>";
       }
    ?>
          <select name="Country" style="width:220px "> 
          <?php
            echo "<option value=\"\">&nbsp;</option>".$str;
          ?>
         </select></td></tr>
    <tr><td>&nbsp;State Code</td>
    <td>
          <select name="StateCd" style="width:220px "> <?php
       $str = ""; //重置$str
       $sresult=mysql_query("select StateCd,StateName from state",$conn);
       while ($srow=mysql_fetch_array($sresult)) {
       $StateCd=$srow['StateCd'];
       $str.="<option value=$StateCd>".$srow['StateName']."</option>";
       }
    ?>
         </select></td></tr>
    这样看看