需要帮助才能获得如下结果我已经尝试了很多但无法成功。计算日期出现的次数并显示在数组中。[[Date.UTC(2011,9,23),1],[Date.UTC(2011,9,24),2],[Date.UTC(2011,9,25),5]]。
到目前为止,我能够将日期提取为数组格式,下面是我的结果。[[“03-09-2011”],[“06-09-2011”],[“06-09-2011”]]。如何添加另一行以显示每个日期和日期 Date.UTC 的计数?
请帮忙
我的代码
$mysql_connect = mysql_connect($db_host, $db_user, $db_pword, $db_name);
$query = "SELECT DATE_FORMAT(`timestamp`,'%d-%m-%Y') as date from mytable";
if (!$mysql_connect) die("unable to connect to database: " . mysql_error());
@mysql_select_db($db_name) or die( "Unable to select database");
$result = mysql_query($query);
$response = array();
$stats = array();
while($row=mysql_fetch_array($result))
{
$date = $row ['date'];
$stats[] = array ($date);
}
$Response[] = $stats;
$fp = fopen('results.json', 'w');
fwrite($fp, json_encode($Response));
fclose($fp);
//die ("Failed to execute Query: " . mysql_error());
mysql_close($mysql_connect);