我想回顯json格式的數組,但沒有標籤,只能使用值。如何打印沒有標籤的json格式的php數組
我有這個backsearch.php
<?php
// if the 'term' variable is not sent with the request, exit
if (!isset($_REQUEST['term']))
exit;
$data = array();
$con=mysql_connect("localhost","root","");
$db=mysql_select_db("Fw.To",$con);
$rs=mysql_query('select * from Users where Owner LIKE "'. mysql_real_escape_string($_REQUEST['term']) .'%"', $db);
if ($rs && mysql_num_rows($rs))
{
while($row = mysql_fetch_array($rs, MYSQL_ASSOC))
{
array_push($data, $row['Owner']);
}
}
echo json_encode($data);
flush();
?>
,並在我的HTML這個JavaScript的jQuery的內部在那裏等待的唯一價值JSON
<script>
jQuery(document).ready(function($){
$('#search').autocomplete({source: 'backsearch.php'});
});
</script>
任何想法?
編輯:我想把[[紅色],「藍色」,「黃色」]給它在JavaScript和沒有{「0」:紅色,「1」:藍色,「3」:黃色}
我不明白,這將使無效的JSON代碼。你可以包含一個你想要返回的代碼的例子嗎? – Twisty
所需的輸出將是有益的,你應該開始使用mysqli insted mysql。問題知道爲什麼。http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php –
當然,我可以...我想採取[「」,「 'bar'「,」\「baz \」「,」&blong&「,」\ u00e9「]給它的JavaScript和不是{」a「:1,」b「:2,」c「:3,」d 「:4,」e「:5} –