! このようなチェックボックスを使用して現在の月の日付を印刷したい場合は、2013 年 1 月 3 日からチェックボックス [] 、2013 年 2 月 3 日 [] から月末まで、31 の日付と 31 のチェックボックスを使用します。配列 $isActive = $attendancelis['EmployeeAttendance']['is_active']; のチェックボックスの値。すべてのチェックボックスに $isActive 値が必要です。次はの出力ですprint_r($attendancelis);
:
Array ( [EmployeeAttendance] => Array ( [id] => 5 [employee_id] => 8 [is_active] => 1 [date] => 2013-03-21 11:15:17 [day_month_year] => 2323123 ) ) Array ( [EmployeeAttendance] => Array ( [id] => 3 [employee_id] => 8 [is_active] => 1 [date] => 2013-03-12 17:47:03 [day_month_year] => 23213213 ) )
Array ( [EmployeeAttendance] => Array ( [id] => 0 [employee_id] => 8 [is_active] => 1 [date] => 2013-03-16 13:11:58 [day_month_year] => 324234324 ) ) -->
これは私のコードです:
<?php
$nrDaysCurrentMonth = date("t");
for($dayNr = 1; $dayNr <= $nrDaysCurrentMonth; $dayNr++)
{
echo'<div style="width:300px;float:left;">';
echo date(''.$dayNr.'-m-Y');
echo '<input name="frmEmployeeAttendance[]" type="checkbox" value="0" />';
foreach($attendanceList as $attendanceLis)
{
$isActivee = $attendanceLis['EmployeeAttendance']['date'];
$isActiveYM = strtotime(date('d-m-Y', strtotime($isActivee)));
$isActiveYMD = date('j', strtotime($isActivee));
if($dayNr==$isActiveYMD) {
$isActive = $attendanceLis['EmployeeAttendance']['is_active'];
if ($isActive){
echo '<input name="frmEmployeeAttendance[]" type="checkbox" checked=="checked" value="' . $isActive . '" />';
}
else {
echo '<input name="frmEmployeeAttendance[]" type="checkbox" value="' . $isActive . '" />';
}
}
}
echo '<br/>';
echo'</div>';
}
?>