Home  >  Article  >  Backend Development  >  Get the number of loops in php while loop_PHP tutorial

Get the number of loops in php while loop_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:25:46771browse

Copy code The code is as follows:

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

It is occasionally used in actual work.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/824936.htmlTechArticleCopy the code as follows: ?php $link = mysql_connect('localhost','root','pwd') ; mysql_select_db('db'); $sql = "select region_id,local_name from regions where region_grade=1"; $res...
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