Home > Backend Development > PHP Tutorial > php while循环得到循环次数_php实例

php while循环得到循环次数_php实例

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-17 08:54:21
Original
1190 people have browsed it
复制代码 代码如下:

   $link = mysql_connect('localhost','root','pwd');
   mysql_select_db('db'); 
   $sql = "select region_id,local_name from regions where region_grade=1";
   $result = mysql_query($sql);
 $i =0;
  while ($row= mysql_fetch_assoc($result)) {
        $list[$i]['text']=$row['local_name']; 
        $list[$i]['value']=$row['region_id'];
        $i++;      
   }
  $list = json_encode($list);
  echo   $list;
?>

在实际工作,偶尔会用到的。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template