Home >Backend Development >PHP Tutorial >Example of php while loop recording the number of loops

Example of php while loop recording the number of loops

WBOY
WBOYOriginal
2016-07-25 08:57:441361browse
  1. //Record the number of while loops
  2. //by bbs.it-home.org
  3. $link = mysql_connect('localhost','root','pwd');
  4. mysql_select_db( 'db');
  5. $sql = "select region_id,local_name from regions where region_grade=1";
  6. $result = mysql_query($sql);
  7. $i =0;
  8. while ($row= mysql_fetch_assoc($result)) {
  9. $list[$i]['text']=$row['local_name'];
  10. $list[$i]['value']=$row['region_id'];
  11. $i++;
  12. }
  13. $list = json_encode($list);
  14. echo $list;
  15. ?>
Copy the code

and record it, I might use it one day.



Statement:
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