我必须显示员工周六和周日的记录。我如何使用 php 来做到这一点。
while($row=mysql_fetch_row($res))
{
list($name, $crd,$indate,$in,$out,$t) = $row;
$row[3] = date("g:i A", $in);
$row[4] = date("g:i A" ,$out);
$d3 = date("d-m-Y (D)", $in);
$bg = '';
if(date('D', $in) == 'Sun' || date('D', $in) == 'Sat')
$bg = 'bgcolor=#EEEEEE';
else
$bg = 'bgcolor= #ECE5B6';
if ($ddate != $row[2] && $row[2] != null)
{
echo "<tr $bg><td colspan=4>Date: ".$d3."</td></tr>";
$ddate = $row[2];
}
else if($row[2]==null)
{
$bg = 'bgcolor=#EEEEEE';
echo "<tr $bg><td colspan=4>Date: ".$from."</td></tr>";
}
if ($row[2] != null)
{
echo "<tr>";
echo "<td align=left width='35%'>".trim($name)."</td>";
echo "<td align=center width='20%' >".$row[3]."</td>";
echo "<td align=center width='23%' >".$row[4]."</td>";
echo "<td align=center width='16%'>".$t."</td>";
echo "</tr>";
}
else
{
echo "<tr>";
echo "<td align=left width='35%'>".trim($name)."</td>";
echo "<td align=center width='20%' >Null</td>";
echo "<td align=center width='23%' >Null</td>";
echo "<td align=center width='16%'>".$t."</td>";
echo "</tr>";
}
}
现在这个问题是星期天所有记录都显示没有日期。
mysql是
SELECT mstEmp.empname, mstEmp.cardno, InDate,
dailyattendance.InTime,dailyattendance.OutTime, mstEmp.teamtype
FROM mstEmp
LEFT JOIN dailyattendance
ON (dailyattendance.HolderName = mstEmp.empname )
AND (InDate BETWEEN '$from' AND '$to')
WHERE (mstEmp.teamtype = '$chk')
order by InDate DESC
我有这个代码调用上面的代码
$sFrom = toYYYYMMDD($frm);
$sTo = toYYYYMMDD($t) . " 23:59:59";
while (strtotime($sFrom) <= strtotime($sTo))
{
setvalue($checkbox,$sFrom,$sFrom);
$sFrom = date ("Y-m-d", strtotime("+1 day", strtotime($sFrom)));
}