我试图让标签,它的jQuery插件使用JSON字符串。 Currenttly我很喜欢这让我值从数据库中:PHP的JSON输出与MySQL的标记它
$query = sprintf(
'SELECT
t.tag
FROM
tags AS t
');
$row_set= array();
if($result = mysqli_query($db, $query))
{
// fetch data
while ($row = mysqli_fetch_assoc($result))
{
$row_set[] = $row;
}
// set the output
echo json_encode($row_set);
}
,其给出了AJAX调用时的输出如下:
[{"tag":"test"},{"tag":"tests"}]
但是,我必须输出以下格式的JSON字符串:
["android-intent","animate","architecture","artificial-intelligence","attributes"]
我该如何做到这一点?
这给了我正确的输出,但标签 - 它给所有charachter作为建议自动完成 它给[“test作为单独的‘标签’...... 编辑:请不要介意忘了数据类型: “json”, – kendepelchin 2012-04-28 11:28:08
It it working now .. or you have other issues ??? – Baba 2012-04-28 11:33:03
是的,效果很好,谢谢。 – kendepelchin 2012-04-28 11:36:20