$endDate) { break; } $labels[] = $day; $new = daoInst()->select('*')->from($tabName) ->where('ts')->ge($day . " 00:00:00") ->andWhere('ts')->le($day . " 23:59:59") ->count(); if ($type == 0) { $array[] = $new; } else { $iday2 = strtotime("$day +$type day"); $day2 = date("Y-m-d", $iday2); $total = daoInst()->select('*')->from($tabName) ->where('ts')->ge($day . " 00:00:00") ->andWhere('ts')->le($day . " 23:59:59") ->andWhere('lastlogin')->ge($day2 . " 00:00:00") ->count(); $array[] = (int) ($total / $new * 100); } } $result = new stdClass(); $result->data = $array; $result->labels = $labels; echo json_encode($result);