mysql 數(shù)組循環(huán)查詢,php怎么把接受到的數(shù)據(jù)循環(huán)的添加到數(shù)組?
遍歷數(shù)據(jù)表,把相應(yīng)的數(shù)據(jù)放到數(shù)組中即可例如:<
?php//定義一個數(shù)組,用于保存讀取到的數(shù)據(jù)$contents = array();$query = mysql_query("select * from table")
;//遍歷數(shù)據(jù)表while($array = mysql_fetch_array($query)){$contents[] = $array;
}print_r($contents)
;//然后循環(huán)數(shù)組,或者通過鍵名使用數(shù)組foreach($contents as $value){print_r($value);}echo $contents[0]['字段名稱'];?>