复制代码 代码如下:
$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;
?>
在实际工作,偶尔会用到的。
http://www.bkjia.com/PHPjc/824936.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/824936.htmlTechArticle复制代码 代码如下: ?php $link = mysql_connect('localhost','root','pwd'); mysql_select_db('db'); $sql = "select region_id,local_name from regions where region_grade=1"; $res...