如果有人提交了那个星期的时间表,那么我试图锁定一整周,这样他们就无法编辑/添加已经提交过的那一周的新时间。
我目前有一个checksubmit函数,如果有人提交了该周的时间表,则返回1(检查$ submitendweek,这将是结束周的星期六,即:2013-01-05)
我是非常新的编程和语言php / mysql所以我为缺乏PHP知识而道歉。
这是暂时使用的,但非常恶心,并且没有捕捉上个月的日子......比如30日或31日。
$submitted = checksubmit($contextUser, $year, $month, $curDay);
$submitted1 = checksubmit($contextUser, $year, $month, $curDay+1);
$submitted2 = checksubmit($contextUser, $year, $month, $curDay+2);
$submitted3 = checksubmit($contextUser, $year, $month, $curDay+3);
$submitted4 = checksubmit($contextUser, $year, $month, $curDay+4);
$submitted5 = checksubmit($contextUser, $year, $month, $curDay+5);
$submitted6 = checksubmit($contextUser, $year, $month, $curDay+6);
if ($submitted || $submitted1 || $submitted2 || $submitted3 || $submitted4 || $submitted5 || $submitted6) {
print "submitted already";
...more
} else {
print "submit button";
...more
}
答案 0 :(得分:1)
for循环可以帮助你。
$submitted = false;
for($i = 0; $i < 7; $i++) {
if(checksubmit($contextUser, $year, $month, $curDay + $i)) {
print 'submitted already';
// one was sumbitted
$submitted = true;
break;
}
}
if(!$sumbitted) {
print 'submit button';
// none were submitted this week
}