我想按日期汇总数据组
示例数据
{"reqtime":"Monday, July 30, 2012 08:55:45","user_id":"9704"},
{"reqtime":"Tuesday, September 4, 2012 11:07:11","user_id":"9717"},
{"reqtime":"Thursday, September 13, 2012 07:41:41","user_id":"9720"},
{"reqtime":"Friday, October 12, 2012 10:20:19","user_id":"9731"},
{"reqtime":"Friday, October 19, 2012 10:20:14","user_id":"9726"},
{"reqtime":"Monday, November 26, 2012 18:42:00","user_id":"9701"}
{"reqtime":"Thursday, December 6, 2012 11:33:52","user_id":"9728"},
{"reqtime":"Monday, December 10, 2012 02:55:53","user_id":"10282"},
{"reqtime":"Monday, December 10, 2012 03:02:24","user_id":"10284"},
{"reqtime":"Monday, December 10, 2012 04:02:57","user_id":"10286"},
{"reqtime":"Monday, December 10, 2012 04:18:29","user_id":"9944"},
{"reqtime":"Monday, December 10, 2012 05:22:38","user_id":"10292"},
{"reqtime":"Monday, December 10, 2012 05:23:05","user_id":"10291"},
变成这样
例子 :
dec 10 : 6 user_id /*( **sum user_id but sorting by date** )*/
这是我的代码/脚本尚未求和,n 尚未编码为 json :
$query = "SELECT * FROM `users_demoid` order by reqtime LIMIT 0 , 100";
$result = mysql_query($query) or die("SQL Error 1: " . mysql_error());
// get data and store in a json array
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$date=date("l, F j, Y H:i:s",$row['reqtime']);
$orders[] = array(
'reqtime' => $date,
'user_id' => $row['user_id']
);
}
提前致谢