这可能吗? 我有一个查询从表中选择所有记录,结果基于时间字段。这是一个为期17周的游戏时间表。我想要做的是创建一个只有当前已经过期的周游戏的数组。在我的下面的代码中,每个过期的游戏都会显示在数组中。是否有可能只创建这个单独的数组,只包括当前的周游戏?我仍然需要捕获所有数据,但我正在尝试为当前周创建一个数据数组,如代码的行过期部分所示。
$latestweek = getCurrentWeek(); //gives the current week
for($wk=1;$wk<=17;$wk++){
$games = array();
$sql = "select s.*, (DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) > gameTimeEastern or DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) > '" . $cutoffDateTime . "') as expired ";
$sql .= "from " . DB_PREFIX . "schedule s ";
$sql .= "where s.weekNum = " . $wk . " ";
$sql .= "order by s.gameTimeEastern, s.gameID";
$query = $mysqli->query($sql);
if ($query->num_rows > 0) {
$e = 0;
while ($row = $query->fetch_assoc()) {
$games[$row['gameID']]['gameID'] = $row['gameID'];
$games[$row['gameID']]['homeID'] = $row['homeID'];
$games[$row['gameID']]['visitorID'] = $row['visitorID'];
$games[$row['gameID']]['sWinner'] = $row['result'];
$games[$row['gameID']]['startTime'] = $row['gameTimeEastern'];
if ($row['expired']){
$survGamesExpired_h[$e]=$row['homeID'];
$survGamesExpired_v[$e]=$row['visitorID'];
}
$expiredTeams = array_merge((array)$survGamesExpired_h,(array)$survGamesExpired_v);
}
}