以前問過這個問題,但是我已經將這個問題縮小到了這一點代碼。這裏是我的代碼,當我運行它,它只是說「空」 ..如何爲json格式化Mysql/php數組?
$getmsg = "SELECT * FROM user WHERE account_id = $id";
$showmsg = @mysqli_query ($dbc, $getmsg);
while ($row = mysqli_fetch_array($showmsg, MYSQLI_ASSOC)) {
$arrResults = array($row['user_username']);
} // END WHILE
// Print them out, one per line
echo json_encode($arrResults);
我想我在這裏找到了你以前放棄的問題,我們縮小了它:http://stackoverflow.com/questions/5902397/how-to-use-jquery-to-autocomplete-with-usernames-for-a- message-app/5902648這是黑幕。 – Beez 2011-05-05 19:16:20