$sql = "SELECT * FROM `jos_users` LIMIT 0, 30 ";
$response = array();
$posts = array();
$result=mysql_query($sql);
while($row=mysql_fetch_array($result))
{
$id=$row['id'];
$id=$row['name'];
$posts[] = array('id'=> $title, 'name'=> $name);
}
$response['jos_users'] = $posts;
$fp = fopen('results.json', 'w');
fwrite($fp, json_encode($response));
fclose($fp);
我想将用户 id 和名称获取到 json 文件。我认为 id 代码错误。有人可以纠正吗?