我的桌子看起来像:
id | title | link | kind
------------------------
1 link1 http one
4 link2 http two
2 link9 http one
我想返回一个 JSON 数组(JSON 解析不是问题!),它看起来像:
one
- link1, http
- link9, http
two
- link2, http
kind-colum 是动态的,所以我不知道实际的字符串。(但它永远不是(空)!)
是)我有的:
$links = array();
while($row = mysql_fetch_object($result)) {
$link = array(
'title' => $row->title,
'link' => $row->link,
'kind' => $row->kind
);
$links[] = $link;
}
echo json_encode($links);
这是一个包含每个元素的所有列的数组。