当前位置: 代码迷 >> PHP >> 請問一這種陣列要怎么充值
  详细解决方案

請問一這種陣列要怎么充值

热度:79   发布时间:2016-04-28 23:44:02.0
請問一這種陣列要如何充值?
請教大家,有一個陣列,想從資料表取出值來填入,要怎麼改呢?

PHP code
$sql = "select sid,township from tbl_township where pid=1";$res = db_query($sql);            while (list($sid,$township)=mysql_fetch_row($res)):       endwhile; 


陣列型式如下:
PHP code
$provinces = array(array('sid' => 'bj', 'township' => 'Beijing'),array('sid' => 'hb', 'township' => 'Hubei'));


------解决方案--------------------
while($row = mysql_fetch_assoc($res)) {
$provinces[] = $row;
}
  相关解决方案