欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php while循環(huán)得到循環(huán)次數(shù)

 更新時間:2013年10月26日 09:47:48   作者:  
在for循環(huán)中,我們很容易得到循環(huán)次數(shù),因為是作為條件出現(xiàn)的。在while也可以得到,如下:
復(fù)制代碼 代碼如下:

<?php
   $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;
?>

在實際工作,偶爾會用到的。

相關(guān)文章

最新評論