如果您查看下面的代码,您会看到一个选择选项,其中包含所有NFL球队作为选项,IF语句在某些条件下禁用它们。
我想根据他们在赛季中的比赛日期禁用球队。
例如,如果两支球队在周一晚上8点参加比赛,那么我希望这两支球队在晚上7点至周三上午6:00或周日下午1:00至6:00等禁用。
我的问题是每个团队每周都会进行更改的日期/时间。我不知道如何设置它以自动知道要禁用哪些团队。我现在拥有的是一个手动设置,当每个团队每周使用“strtotime()”禁用时,我会更改。不确定这是否是最佳方式,一些澄清会有所帮助!
<?php
$tt = date("h"); // hours 1-12
$current = date("h:i:sa"); // Current time of day
$sundayaftr = strtotime("3:00pm Sunday");
$sundaymorn = strtotime("12:00pm Sunday");
$thurs = strtotime("7:00pm Thursday");
$mon = strtotime("7:00pm Monday");
$start = strtotime("6:00am Wednesday");
$close = strtotime("8:00pm Sunday");
// Locks option based on condition
if(($current >= $thurs) && ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="wr"'.$dis.'>Washington Redskins</option>';
if(($current >= $mon) && ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="nyg"'.$dis.'>New York Giants</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="pe"'.$dis.'>Philadelphia Eagles</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="dc"'.$dis.'>Dallas Cowboys</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="br"'.$dis.'>Baltimore Ravens</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="ps"'.$dis.'>Pittsburgh Steelers</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="tt"'.$dis.'>Tennessee Titans</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="gbp"'.$dis.'>Green Bay Packers</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="ss"'.$dis.'>Seattle Seahawks</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="cbr"'.$dis.'>Cleveland Browns</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="bb"'.$dis.'>Buffalo Bills</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="jj"'.$dis.'>Jacksonville Jaguars</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="ic"'.$dis.'>Indianapolis Colts</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="ht"'.$dis.'>Houston Texans</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="kcc"'.$dis.'>Kansas City Chiefs</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="md"'.$dis.'>Miami Dolphins</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="nep"'.$dis.'>New England Patriots</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="nyj"'.$dis.'>New York Jets</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="slr"'.$dis.'>Saint Louis Rams</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="nos"'.$dis.'>New Orleans Saints</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="mv"'.$dis.'>Minnesota Vikings</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="tbb"'.$dis.'>Tampa Bay Buccaneers</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="ac"'.$dis.'>Arizona Cardinals</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="af"'.$dis.'>Atlanta Falcons</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="sf49"'.$dis.'>San Francisco 49ers</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="sdc"'.$dis.'>San Diego Chargers</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="or"'.$dis.'>Oakland Raiders</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="db"'.$dis.'>Denver Broncos</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="cbe"'.$dis.'>Cincinnati Bengals</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="cp"'.$dis.'>Carolina Panthers</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="dl"'.$dis.'>Detroit Lions</option>';
if(($current >= $thurs) || ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="cbea"'.$dis.'>Chicago Bears</option>';
?>