我的代码函数是在选定年份的范围内从/到达所有值。
我有2个下拉菜单供用户选择季节/年。但是我有一个错误,如果游览的季节从/到小于/大于选定年份,我就无法获得价值。例如:
从/到的选定季节:2015-2016
from to
2011-05-06 2014-11-12 (not get - work)
2012-04-01 2015-12-31 (get - work)
2015-01-01 2016-08-10 (get - work)
2016-08-11 2018-12-28 (get - work)
2017-01-01 2018-01-01 (not get - work)
2014-01-11 2017-01-01 (I want get this too, because my selected year is 2015-2016)
我的代码:
$first_day = mktime(0, 0, 0, 1, 1, $params['seasonfrom']) ; //2015-01-01
$first_day = "'".date('Y-m-d',$first_day)."'";
$last_day = mktime(0, 0, 0, 12, 31, $params['seasonto']) ; //2016-12-31
$last_day = "'".date('Y-m-d',$last_day)."'";
$str1.="(ts.SsnFrom >= {$first_day} AND ts.SsnFrom <={$last_day}
OR ts.SsnTo >= {$first_day} AND ts.SsnTo <={$last_day})";
有人给我一个解决方案。谢谢!!
答案 0 :(得分:0)
我不懂PHP。一般暗示这一点。这可能会对你有帮助。
$str1.="({$first_day} BETWEEN ts.SsnFrom AND ts.SsnTo OR {$last_day} BETWEEN ts.SsnFrom AND ts.SsnTo)";