Example of php while loop recording the number of loops

WBOY
Release: 2016-07-25 08:57:44
Original
1341 people have browsed it
  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.



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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!