$retrieve = mysql_query("SELECT * FROM `users`") or die(mysql_error());
$object -> userDetails = array();
while($retrieveArray = mysql_fetch_array($retrieve))
{
$item -> userId = $retrieveArray['id'];
$item -> userEmail = $retrieveArray['email'];
$item -> userLocation = $retrieveArray['location'];
$item -> userFirstName = $retrieveArray['firstname'];
$item -> userLastName = $retrieveArray['lastname'];
$object ->userDetails[] = $item;
}
$json = json_encode($object);
echo $json;
这段代码有问题吗?我的输出只显示我的数据库的第一行。
{"userDetails":[{"userId":"1","userEmail":"EmailAddress@gmail.com","userLocation":"HomeAddress","userFirstName":"Allan","userLastName":"Knocks"}]}