$result = mysql_query("SELECT area_name,area_parent_id,area_id FROM shopnc_area where area_id>5 and area_deep<3 order by area_sort asc,area_id asc");
$area_array=array();
while($row = mysql_fetch_array($result))
{
不知道怎么写了。
}
想要的数据库格式:
$area_array = array (
2 => array ( 'area_name' => '天津', 'area_parent_id' => '0', ),
40 => array ( 'area_name' => '天津', 'area_parent_id' => '2', ),
);
其中:2,40的值为area_id的值。谢谢。
------解决思路----------------------
while($row = mysql_fetch_array($result)){
$area_array[$row['area_id']]['area_name'] = $row['area_name'];
$area_array[$row['area_id']]['area_parent_id'] = $row['area_parent_id'];
}