1

目前我的数据库存储电子邮件和收集的日期。我想建立一个图表来显示每天收集了多少电子邮件。我找到了一个使用 idiORM 的教程,但是这个图表显示了从数据库返回的值,而不是计算返回的数量。

关于如何计算每个结果的任何想法?

if (isset($_GET['start']) AND isset($_GET['end'])) {

$start = $_GET['start'];
$end = $_GET['end'];
$data = array();

// Select the results with Idiorm
$results = ORM::for_table('tbl_data')
        ->where_gte('date', $start)
        ->where_lte('date', $end)
        ->order_by_desc('date')
        ->find_array();


// Build a new array with the data
foreach ($results as $key => $value) {
    $data[$key]['label'] = $value['date'];
    $data[$key]['value'] = $value['email'];
}

echo json_encode($data);
}
4

0 回答 0