} else { if ($type == 2) { $type = "骑行"; } else { if ($type == 3) { $type = "瑜伽"; } else { if ($type == 4) { $type = "散步"; } else { $type = "健身"; } } } } $exenode = array("date" => $date, "exetime" => calTime($exetime), "calorie" => $calorie, "type" => $type); foreach ($exenode as $key => $value) { $exenode[$key] = urlencode($value); } if ($count > 0) { $exelist = $exelist . ','; } $exelist = $exelist . urldecode(json_encode($exenode)); $count = $count + 1; } $exelist = $exelist . ']'; echo $exelist; } else { echo false; } }
$first_day_of_month = date('Y-m-01', $datetime); $checksql = "Select * from Sleep where userid = '{$idtocheck}' and endTime<'{$tomorrow}' and endTime>='{$first_day_of_month}' order by endTime desc limit 10"; } if ($listType == "year") { $first_day_of_year = date('Y-01-01', $datetime); $checksql = "Select * from Sleep where userid = '{$idtocheck}' and endTime<'{$tomorrow}' and endTime>='{$first_day_of_year}' order by endTime desc limit 10"; } $result = $db->query($checksql); $exelist = '['; $count = 0; while ($row = $result->fetchArray(SQLITE3_ASSOC)) { $slptime = strtotime($row['endTime']) - strtotime($row['startTime']); $start = date('Y-m-d H:m:s', strtotime($row['startTime'])); $end = date('Y-m-d H:m:s', strtotime($row['endTime'])); $fullslp = calTime(strtotime($row['fullend']) - strtotime($row['fullstart'])); $slpnode = array("start" => $start, "end" => $end, "slptime" => calTime($slptime), "fullslptime" => $fullslp); foreach ($slpnode as $key => $value) { $slpnode[$key] = urlencode($value); } if ($count > 0) { $exelist = $exelist . ','; } $exelist = $exelist . urldecode(json_encode($slpnode)); $count = $count + 1; } $exelist = $exelist . ']'; echo $exelist; } else { echo false; } }