在数据库PHP中显示来自state id的城市

时间:2016-06-14 11:53:22

标签: php state show city

我正在尝试建立一个php网站

在注册页面中我用户必须选择状态(选择输入),然后城市输入将在他选择状态后出现。

这是我的工作,但不起作用,我需要正确或其他解决方案来解决它:

>     $states = get_states();
>     
>     if($states == NULL)
>       die('Problem');
>     
>     $scount = count($states);
>     if($scount == 0)
>       die('No States');

// ******************

 <?php
    if(isset($_POST['state']))
  {
      for($i=0; $i < $scount; $i++)
      {
          $state = $states[$i];
          if($_POST['state'] = $state->name)
          {
              $regions = get_regions_by_state($state->id);

              if($regions == NULL)
                  die('Problem');

                $rcount = count($regions);

                if($rcount == 0)
                  die('No regions');

              for ($i=0; $i < $rcount; $i++)
              {
                  $region = $region[$i];
                  echo "<option value=\"$region->id\">$region->name</option>";        
              }

          }
        }         
  }
  ?>

0 个答案:

没有答案