我无法从数据库中获取我的值以进入 jquery 标签插件,任何帮助都会很棒:
PHP:
case 'get_tags':
$id = (isset($_GET['id'])) ? intval($_GET['id']) : 0;
$query = "SELECT description FROM `tags` WHERE page_id = '?';";
$query_p = $db->prep_query($query,array($id));
$results = $db->queryMakearray($query_p);
$tags = array_values($results);
$response = json_encode($results);
break;
JS
$(document).ready(function()
{
var _id = parseInt($.url_param('id'), 10);
var _tag_items = $.get('inc/ajax.php?type=get_tags&id='+_id);
$('#tags')
.textext({
plugins : 'tags',
tagsItems: _tag_items
});
});
回复:
"[{\"description\":\"test\"},{\"description\":\"test2\"},{\"description\":\"test3\"}]"
我需要它看起来像这样:
["test","test2","test3"]
编辑
PHP:
$id = (isset($_GET['id'])) ? intval($_GET['id']) : 0;
$query = "SELECT description FROM `tags` WHERE page_id = '?';";
$query_p = $db->prep_query($query,array($id));
$results = $db->query2array($query_p);
$tags = array_values($results);
$response = sanitize_output($tags);