0
我正在使用在stackoverflow上找到的此解決方案將我的MYSQL輸出編碼爲JSON編碼數組。將項目添加到JSON編碼數組
$sth = mysql_query("SELECT ...");
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$rows[] = $r;
}
print json_encode($rows);
這個偉大的工程和生產的
[{"id":"81","title":"Something Here","start":"2009-10-27 09:00:00"},{"id":"77","title":"Report on water","start":"2009-10-30 09:00:00"}]
輸出現在我需要把一個值的說
"colour":"Blue"
的JSON編碼數組內。
所以我需要的輸出中看起來像
[{"id":"81","title":"Community Awareness","start":"2009-10-27 09:00:00", "colour":"Blue"},{"id":"77","title":"Write a 10,000 Page Report on Emma","start":"2009-10-30 09:00:00", "colour":"Blue"}]
有沒有人對我怎麼能做到這一點的任何解決方案?
感謝,
蒂姆·莫爾
謝謝!就是這樣 – Tim 2009-11-18 04:52:16