要获得的效果是:[{"name":"aaa","id":"1","sex","man"},{"name":"bbb","id":"2","sex","woman"},{}...]现在的显示是{"name":"aaa","id":"1","sex","man"}{"name":"bbb","id":"2","sex","woman"}{}...我的代码:
2 回答
慕尼黑8549860
TA贡献1818条经验 获得超11个赞
已解决defined('BASEPATH')ORexit('Nodirectscriptaccessallowed');classDemoextendsCI_Controller{publicfunctionindex(){$con=mysqli_connect("localhost","root","***","test");//输出中文可以加一句mysqli_query($con,"SETNAMESutf8");$query=mysqli_query($con,"select*fromuser");$array=array();while($row=mysqli_fetch_assoc($query)){$array[]=$row;}echojson_encode($array);}}
桃花长相依
TA贡献1860条经验 获得超8个赞
publicfunctionindex(){$this->load->database();$query=$this->db->query('SELECTname,id,sexFROMuser');echojson_encode($query);}这样不久可以了吗
添加回答
举报
0/150
提交
取消