本帖最后由 mxh861001 于 2014-05-19 21:12:45 编辑
<br />foreach ($query->result_array() as $row)<br /> {<br /> $data = array(<br /> 'id' => $row['id'],<br /> 'title' =>$row['title']<br /> );<br /> }<br /><br />echo json_encode($data);<br />
前端为何只输了一组数据?
CI框架
({"id":"2","title":"\u65b0\u7586VS\u5317\u4eac"})
------解决方案--------------------foreach ($query->result_array() as $row)
{
$data[] = array(
'id' => $row['id'],
'title' =>$row['title']
);
}