我正在从这样的Mysql数据库中读取数据:
$result = mysqli_query($con,"SELECT * FROM myTable");
while($row = mysqli_fetch_array($result))
{
echo $row['field1'] . " " . $row['field2'];
}
而不是输出这样的记录:
echo $row['field1'] . " " . $row['field2'];
我需要将它们变成以下格式:
$list = array(
array('field1'=>'something here', 'field2'=>'something else')
);
我该怎么做?
答案 0 :(得分:2)
$result = mysqli_query($con,"SELECT * FROM myTable");
while($row = mysqli_fetch_array($result)){
$list[] = $row;
}