我几天来一直在努力解决这个问题而且找不到合适的解决方案.
我想通过PHP从这个数据库表中检索数据:
而且,再次使用php,有一个类似于此的JSON输出:
[{
"label": "2013-01-07",
"value": "4"
}, {
"label": "2013-01-06",
"value": "65"
}, {
"label": "2013-01-05",
"value": "96"
}]
Run Code Online (Sandbox Code Playgroud)
我写了一个函数,从表中检索信息,但我不能按正确的顺序排列它们,也有更好的方法来做它.
function getUsersCountOnDate()
{
$result = mysql_query("Select FROM_UNIXTIME(regtime, '%Y-%m-%d') as date, count(FROM_UNIXTIME(regtime, '%Y-%m-%d')) as count from users group by FROM_UNIXTIME(regtime, '%Y-%m-%d') order by FROM_UNIXTIME(regtime, '%Y-%m-%d') DESC");
while($row = mysql_fetch_array($result)){
$date[] = $row['date'];
}
$result = mysql_query("Select FROM_UNIXTIME(regtime, '%Y-%m-%d') as date, count(FROM_UNIXTIME(regtime, '%Y-%m-%d')) as count from users group by FROM_UNIXTIME(regtime, '%Y-%m-%d') order by FROM_UNIXTIME(regtime, '%Y-%m-%d') DESC");
while($row = mysql_fetch_array($result)){ …Run Code Online (Sandbox Code Playgroud)