这是代码
$search_sql = "SELECT * FROM logs WHERE from_unixtime(timestamp, '%e %b %Y') BETWEEN '$from_date_string' AND '$to_date_string' ";
$search_result = mysql_query($search_sql) or die(mysql_error());
$search_total = mysql_num_rows($search_result);
var dataTable2 = google.visualization.arrayToDataTable([
["Date From", "Result"],
["' . $from_date_string .'", ' . $search_total2 . '],
< INSERT LOOP EACH DATE BETWEEN HERE >
["' . $to_date_string .'", ' . $search_total3 . ']
]);
基本上我想将Inbetween Days添加到Google Chart DataTable2中的From和To。
我认为这将是一个foreach记录,但我不知道从哪里开始。
日期格式示例 - 1月13日
while ($row = mysql_fetch_array($search_result_loop)){
echo "['Date', 200], \n";
}
我需要上面的这一点,以便每天在From和To日期之间给我
答案 0 :(得分:0)
考虑使用查询按日期对结果进行分组,例如:
select
from_unixtime(timestamp, '%e %b %Y') as somedate,
count(*) as 'searchtotal'
from logs
where from_unixtime(timestamp, '%e %b %Y') BETWEEN '$from_date_string' AND '$to_date_string'
group by somedate