我基本上创建了一个日历,我想要显示学生的出勤率。如果学生为present
或absent
,则计数器应分别增加到+1
。但问题是,如果在某个地方未记录日历日期的出勤率,则计数器无法增加present
或absent
的值。
这是代码:
$present_sids = explode(",",$a['present_sids']);
$absent_sids = explode(",",$a['absent_sids']);
$leave_sids = explode(",",$a['leave_sids']);
if ($a['att_date'] == "1")
{
if (in_array($sid,$present_sids))
{
$red_green_1 = '70ff7d';
$present_counter = '1';
}
elseif (in_array($sid,$absent_sids))
{
$red_green_1 = 'ff8b70';
$absent_counter = '1';
if (in_array($sid,$leave_sids))
{
$l_1 = ' (L)';
}
else
{
$l_1 = '';
}
}
}
if ($a['att_date'] == "2")
{
if (in_array($sid,$present_sids))
{
$red_green_2 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_2 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_2 = ' (L)';
}
else
{
$l_2 = '';
}
}
}
if ($a['att_date'] == "3")
{
if (in_array($sid,$present_sids))
{
$red_green_3 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_3 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_3 = ' (L)';
}
else
{
$l_3 = '';
}
}
}
if ($a['att_date'] == "4")
{
if (in_array($sid,$present_sids))
{
$red_green_4 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_4 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_4 = ' (L)';
}
else
{
$l_4 = '';
}
}
}
if ($a['att_date'] == "5")
{
if (in_array($sid,$present_sids))
{
$red_green_5 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_5 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_5 = ' (L)';
}
else
{
$l_5 = '';
}
}
}
if ($a['att_date'] == "6")
{
if (in_array($sid,$present_sids))
{
$red_green_6 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_6 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_6 = ' (L)';
}
else
{
$l_6 = '';
}
}
}
if ($a['att_date'] == "7")
{
if (in_array($sid,$present_sids))
{
$red_green_7 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_7 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_7 = ' (L)';
}
else
{
$l_7 = '';
}
}
}
if ($a['att_date'] == "8")
{
if (in_array($sid,$present_sids))
{
$red_green_8 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_8 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_8 = ' (L)';
}
else
{
$l_8 = '';
}
}
}
if ($a['att_date'] == "9")
{
if (in_array($sid,$present_sids))
{
$red_green_9 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_9 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_9 = ' (L)';
}
else
{
$l_9 = '';
}
}
}
if ($a['att_date'] == "10")
{
if (in_array($sid,$present_sids))
{
$red_green_10 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_10 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_10 = ' (L)';
}
else
{
$l_10 = '';
}
}
}
if ($a['att_date'] == "11")
{
if (in_array($sid,$present_sids))
{
$red_green_11 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_11 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_11 = ' (L)';
}
else
{
$l_11 = '';
}
}
}
if ($a['att_date'] == "12")
{
if (in_array($sid,$present_sids))
{
$red_green_12 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_12 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_12 = ' (L)';
}
else
{
$l_12 = '';
}
}
}
if ($a['att_date'] == "13")
{
if (in_array($sid,$present_sids))
{
$red_green_13 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_13 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_13 = ' (L)';
}
else
{
$l_13 = '';
}
}
}
if ($a['att_date'] == "14")
{
if (in_array($sid,$present_sids))
{
$red_green_14 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_14 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_14 = ' (L)';
}
else
{
$l_14 = '';
}
}
}
if ($a['att_date'] == "15")
{
if (in_array($sid,$present_sids))
{
$red_green_15 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_15 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_15 = ' (L)';
}
else
{
$l_15 = '';
}
}
}
if ($a['att_date'] == "16")
{
if (in_array($sid,$present_sids))
{
$red_green_16 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_16 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_16 = ' (L)';
}
else
{
$l_16 = '';
}
}
}
if ($a['att_date'] == "17")
{
if (in_array($sid,$present_sids))
{
$red_green_17 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_17 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_17 = ' (L)';
}
else
{
$l_17 = '';
}
}
}
if ($a['att_date'] == "18")
{
if (in_array($sid,$present_sids))
{
$red_green_18 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_18 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_18 = ' (L)';
}
else
{
$l_18 = '';
}
}
}
if ($a['att_date'] == "19")
{
if (in_array($sid,$present_sids))
{
$red_green_19 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_19 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_19 = ' (L)';
}
else
{
$l_19 = '';
}
}
}
if ($a['att_date'] == "20")
{
if (in_array($sid,$present_sids))
{
$red_green_20 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_20 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_20 = ' (L)';
}
else
{
$l_20 = '';
}
}
}
if ($a['att_date'] == "21")
{
if (in_array($sid,$present_sids))
{
$red_green_21 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_21 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_21 = ' (L)';
}
else
{
$l_21 = '';
}
}
}
if ($a['att_date'] == "22")
{
if (in_array($sid,$present_sids))
{
$red_green_22 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_22 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_22 = ' (L)';
}
else
{
$l_22 = '';
}
}
}
if ($a['att_date'] == "23")
{
if (in_array($sid,$present_sids))
{
$red_green_23 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_23 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_23 = ' (L)';
}
else
{
$l_23 = '';
}
}
}
if ($a['att_date'] == "24")
{
if (in_array($sid,$present_sids))
{
$red_green_24 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_24 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_24 = ' (L)';
}
else
{
$l_24 = '';
}
}
}
if ($a['att_date'] == "25")
{
if (in_array($sid,$present_sids))
{
$red_green_25 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_25 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_25 = ' (L)';
}
else
{
$l_25 = '';
}
}
}
if ($a['att_date'] == "26")
{
if (in_array($sid,$present_sids))
{
$red_green_26 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_26 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_26 = ' (L)';
}
else
{
$l_26 = '';
}
}
}
if ($a['att_date'] == "27")
{
if (in_array($sid,$present_sids))
{
$red_green_27 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_27 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_27 = ' (L)';
}
else
{
$l_27 = '';
}
}
}
if ($a['att_date'] == "28")
{
if (in_array($sid,$present_sids))
{
$red_green_28 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_28 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_28 = ' (L)';
}
else
{
$l_28 = '';
}
}
}
if ($a['att_date'] == "29")
{
if (in_array($sid,$present_sids))
{
$red_green_29 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_29 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_29 = ' (L)';
}
else
{
$l_29 = '';
}
}
}
if ($a['att_date'] == "30")
{
if (in_array($sid,$present_sids))
{
$red_green_30 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_30 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_30 = ' (L)';
}
else
{
$l_30 = '';
}
}
}
if ($a['att_date'] == "31")
{
if (in_array($sid,$present_sids))
{
$red_green_31 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_31 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_31 = ' (L)';
}
else
{
$l_31 = '';
}
}
}
正如您所看到的总礼物数量为6
,但礼物总计数器仅显示4
请帮忙
答案 0 :(得分:0)
我实际上已经开始工作了。我所做的是删除表并重新安装表。我不知道为什么以及如何,但它现在正在发挥作用。
感谢每一个人! :)