我需要从MySQL数据库中导出CSV工作正常,但是如果有一些条件,其中第二个不适合我。它总是出口缺席,假日和周日。但不打印$att[$date]
变量$month
包含年份和月份。喜欢 - 2016-02
$res1 = mysql_query("SELECT *, CONCAT(MIN(`IN_AM`),' ', MAX(`OUT_PM`)) as io_time FROM bio_attandence where date(STR_TO_DATE(attandence_date,'%d/%m/%Y')) >= date('$startdate') AND date(STR_TO_DATE(attandence_date,'%d/%m/%Y')) < date('$enddATE') AND bio_id=".$row['form_no']." GROUP BY bio_id, attandence_date order by attandence_date ");
$att = array();
while ($row1 = mysql_fetch_array($res1)) {
$strtodate = $row1['attandence_date'];
$dateq = str_replace('/', '-', $strtodate);
$dateDate = date('Y-m-d', $dateq);
$att[$dateDate] = $row1['io_time'];
}
for($i=1; $i<32;$i++){
$i = str_pad($i, 2, '0', STR_PAD_LEFT);
$date = $month.'-'.$i;
$val = '';
if(strtotime($date) > strtotime(date('Y-m-d'))){
$val = " ";
}elseif(isset($att[$date])){
$val = $att[$date];
}elseif(isset($holidays[$date])){
$val = $holidays[$date];
}else{
$val = (date('D', strtotime($date)) == 'Sun')? 'Sunday': 'Absent';
}
?>
<Cell>
<Data ss:Type="String"> <?php echo( $val ); ?></Data>
</Cell>
<?php }?>