首页 > 开发 > PHP > 正文

php怎么循环次数?php while循环得到循环次数

2024-05-04 22:01:00
字体:
来源:转载
供稿:网友
  1. <?php 
  2.    $link = mysql_connect('localhost','root','pwd'); 
  3.    mysql_select_db('db');  
  4.    $sql = "select region_id,local_name from regions where region_grade=1"
  5.    $result = mysql_query($sql); 
  6.  $i =0; 
  7.   while ($row= mysql_fetch_assoc($result)) { 
  8.         $list[$i]['text']=$row['local_name'];  
  9.         $list[$i]['value']=$row['region_id']; 
  10.         $i++; //Vevb.com 
  11.    } 
  12.   $list = json_encode($list); 
  13.   echo   $list
  14. ?> 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表