我有一个假期列表。如果假期在我的周开始日期和周结束日期之间,那么奖励的时间将是8。
我遇到的问题是我可以显示8小时(这是包含文件并且值正在另一个PHP文档上显示)但是如果我有一个星期的多个假期它仍然只显示8.我想显示< / p>
一个假期是8个小时 两个假期是16个小时 三个假期是32个小时
依旧等等
我正在弄乱+ =它会起作用但它会显示每周的总金额
这是我的代码
<?
//Holiday List for 2015
//Hours for Holiday
$TestHol = "2015-03-17";
$TestHol2 = "2015-03-16";
$TestHol3 = "2015-03-06";
$NY = "2015-01-01";
$Mem = "2015-05-26";
$V1 = "2015-06-27";
$V2 = "2015-06-30";
$V3 = "2015-07-01";
$V4 = "2015-07-02";
$V5 = "2015-07-03";
$In = "2015-07-04";
$Lab = "2015-09-01";
$Thx = "2015-11-27";
$ThxF = "2015-11-28";
$Chev = "2015-12-24";
$Ch = "2015-12-25";
$V6 = "2015-12-29";
$V7 = "2015-12-30";
$V8 = "2015-12-31";
$holhour = 0;
if(($TestHol>$WBDATE) && ($TestHol<$WEDATE)):
$holhour = 8;
elseif(($TestHol2>$WBDATE) && ($TestHol2<$WEDATE)):
$holhour = 8;
elseif(($TestHol3>$WBDATE) && ($TestHol3<$WEDATE)):
$holhour = 8;
elseif(($NY>$WBDATE) && ($NY<$WEDATE)):
$holhour = 8;
elseif(($Mem>$WBDATE) && ($Mem<$WEDATE)):
$holhour = 8;
elseif(($V1>$WBDATE) && ($V2<$WEDATE)):
$holhour = 8;
elseif(($V2>$WBDATE) && ($V2<$WEDATE)):
$holhour = 8;
elseif(($V3>$WBDATE) && ($V3<$WEDATE)):
$holhour = 8;
elseif(($V4>$WBDATE) && ($V4<$WEDATE)):
$holhour = 8;
elseif(($V5>$WBDATE) && ($V5<$WEDATE)):
$holhour = 8;
elseif(($In>$WBDATE) && ($In<$WEDATE)):
$holhour = 8;
elseif(($Lab>$WBDATE) && ($Lab<$WEDATE)):
$holhour = 8;
elseif(($Thx>$WBDATE) && ($Thx<$WEDATE)):
$holhour = 8;
elseif(($ThxF>$WBDATE) && ($ThxF<$WEDATE)):
$holhour = 8;
elseif(($Chev>$WBDATE) && ($Chev<$WEDATE)):
$holhour = 8;
elseif(($Ch>$WBDATE) && ($Ch<$WEDATE)):
$holhour = 8;
elseif(($V6>$WBDATE) && ($V6<$WEDATE)):
$holhour = 8;
elseif(($V7l>$WBDATE) && ($V7<$WEDATE)):
$holhour = 8;
elseif(($V8>$WBDATE) && ($V8<$WEDATE)):
$holhour = 8;
else :
$holhour = 0;
endif;
?>
答案 0 :(得分:0)
好吧,你没有增加$ holhour的价值。你每次都只分配8。修改为$ holhour = $ holhour + 8; - 每当你想再增加一个假期。 (在你所有的if和elseif语句中,但不是最后一个 - 这就是我猜的)