首頁  >  文章  >  後端開發  >  請問一這種陣列要怎么充值

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

WBOY
WBOY原創
2016-06-13 10:48:08785瀏覽

請問一這種陣列要如何充值?
請教大家,有一個陣列,想從資料表取出值來填入,要怎麼改呢?

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$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
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$provinces = array(array('sid' => 'bj', 'township' => 'Beijing'),array('sid' => 'hb', 'township' => 'Hubei'));


------解决方案--------------------
while($row = mysql_fetch_assoc($res)) {
$provinces[] = $row;
}
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn