因此,对于我的网站,您可以保留某些位置和机器,但是对于机器,需要有老师可用。因此,我需要可以在老师有空时计数的东西。我真的不知道要为此添加什么,但是我所拥有的是一个系统,它可以查看老师的工作日是否为空,如果不为空,它将说一位老师有空。即使它确实很乱,我仍将其包括在内,因为它可能会得到改进。
如果您还不确定我是否真正想要什么,请问一下,这是我第一次在这里问,我也不知道如何问一个好问题。谢谢
$show = new Teacher();
$works = $show->selectWork();
foreach ($works as $work) {
echo '<b>Teacher: </b>'.$work["teacherFirstName"]," ".$work["teacherLastName"] .'<br>';
echo '<b>Days available: </b><br>';
echo '<b>Monday: </b>';
if(!empty($work["workMonday"])) {
echo $work["workMonday"];;
$work["workMonday"] = 'Monday';
} else{
echo 'not available';
}
echo '<br>';
echo '<b>Tuesday: </b>';
if(!empty($work["workTuesday"])) {
echo $work["workTuesday"];
$work["workTuesday"] = 'Tuesday';
} else{
echo 'not available';
}
echo '<br>';
echo '<b>Wednesday: </b>';
if(!empty($work["workWednesday"])) {
echo $work["workWednesday"];;
$work["workWednesday"] = 'Wednesday';
} else{
echo 'not available';
}
echo '<br>';
echo '<b>Thursday: </b>';
if(!empty($work["workThursday"])) {
echo $work["workThursday"];;
$work["workThursday"] = 'Thursday';
} else{
echo 'not available';
}
echo '<br>';
echo '<b>Friday: </b>';
if(!empty($work["workFriday"])) {
echo $work["workFriday"];;
$work["workFriday"] = 'Friday';
} else{
echo 'not available';
}
echo '<br>';
if(isset($work["workMonday"]) && ($work["workTuesday"]) && ($work["workWednesday"]) && ($work["workThursday"]) && ($work["workFriday"])) {
$timestamp = strtotime($_POST['reserveDate']);
$day = date('l', $timestamp);
echo '<b>' . $day . '</b><br>';
if ($day === $work["workMonday"] || $day === $work["workTuesday"] || $day === $work["workWednesday"] || $day === $work["workThursday"] || $day === $work["workFriday"]) {
echo 'someone is availabe';
} else {
echo 'no one is available';
}
}
}
同样,如果对我的代码或我的问题有任何疑问,可以随意提出,我真的需要帮助,为此我需要搜索一些东西,因为它的具体程度,我什么也没得到。
答案 0 :(得分:0)
$totalInMonday = 0;
foreach ($works as $work) {
echo '<b>Teacher:
</b>'.$work["teacherFirstName"]," ".$work["teacherLastName"] .'<br>';
echo '<b>Days available: </b><br>';
echo '<b>Monday: </b>';
if(!empty($work["workMonday"])) {
++$totalInMonday;
echo $work["workMonday"];;
$work["workMonday"] = 'Monday';
} else{
echo 'not available';
}
}
echo $totalInMonday;
您可以整天执行此操作,如果在特定的一天有空,这会增加,结果将存储在echo $totalInMonday
等所有7个变量中,
希望对您有帮助