我有两个表,如下所示:
表:问题
id ~~ quest
———————————————
01 ~~ where is the fruit..?
02 ~~ what is the most popular name in the world..?
表: choice_answer
idq ~~ choice
———————————————
01 ~~ mango
01 ~~ car
01 ~~ bottle
02 ~~ Jhon
02 ~~ Nina
02 ~~ Michael
结果是:
1. "where is the fruit..?"
* mango
* car
* bottle
2. "what is the most popular name in the world..?"
* Jhon
* Nina
* Michael
如何在PHP CodeIgniter上制作数据JSON?如何在IONIC上使用ng-repeat为上面的结果创建视图?
发布于 2016-09-16 19:31:04
您可以从两个表中获取数据,并将两个表数据作为两个不同的数组,然后使用json_encode()并将两个具有两个名称的数组提供给此函数。像这样:
$q = array("q1", "q2");
$a = array("a1", "a2);
echo json_encode(["question" => $q, "content" => $a]);
发布于 2016-09-16 23:18:02
我曾经遇到过这样的问题。Ionic只是不接受正常的回显JSON。
如果你正在使用IONIC,我建议使用来自this的Rest API。只需按照项目中提供的示例操作即可。
https://stackoverflow.com/questions/39530345
复制相似问题