$mysqli = new mysqli('localhost','user','password','myDatabaseName');$myArray = array();if ($result = $mysqli->query("SELECt * FROM phase1")) { while($row = $result->fetch_array(MYSQLI_ASSOC)) { $myArray[] = $row; } echo json_enpre($myArray);}$result->close();$mysqli->close();
$row = $result->fetch_array(MYSQLI_ASSOC)
$myArray[] = $row
这样的输出:
[ {"id":"31","name":"pruduct_name1","price":"98"}, {"id":"30","name":"pruduct_name2","price":"23"}]
$row = $result->fetch_row()
$myArray[] = $row
输出将是这样的:
[ ["31","pruduct_name1","98"], ["30","pruduct_name2","23"]]
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)