2 回答
TA贡献1813条经验 获得超2个赞
大家好,这里就是答案。谢谢你的支持
<?php
$d=cal_days_in_month(CAL_GREGORIAN,date("n"),date("Y"));
$totdate = $d;
$month = date("F");
echo '<table class="table table-striped table-bordered" id="table_content">';
echo "<thead>";
echo "<tr>";
echo "<th>Sl/No</th>";
echo "<th>Emp.ID</th>";
echo "<th>Name</th>";
for ($i=1; $i <= $totdate; $i++) {
echo "<th>".$i."</th>";
}
echo "</tr>";
echo "</thead>";
// $qry = "SELECT * FROM attendance WHERE `month` = '$month'";
$qry ="SELECT * FROM `emp`";
$cnt=1;
$query = mysqli_query($conn, $qry);
foreach ($query as $q) {
$sid = $q['id'];
echo "<tr>";
echo "<td>".$cnt++ ."</td>";
$st_name_id = "SELECT `emp_id`, `name` FROM `emp` WHERE `id`='$sid'";
$re = mysqli_query($conn, $st_name_id);
while ($result = mysqli_fetch_array($re)) {
echo "<td>".$result['emp_id']."</td>";
echo "<td>".$result['name']."</td>";
}
for ($i=1; $i <= $totdate ; $i++) {
$ii = sprintf("%02d", $i);
$qry2 = "SELECT * FROM `attendance` WHERE `empid`='$sid' AND `month`='$month' AND `date`='$ii'";
$re2 = mysqli_query($conn, $qry2);
echo "<td>";
foreach ($re2 as $q) {
$dt = $q['date'];
$s = $q['shift'];
if ($dt == $ii) {
echo $s;
echo "</td>";
}else{
echo "x</td>";
}
}
// echo sprintf("%02d", $i) ."</td>";
}
echo "</tr>";
}
echo "</table>";
作为接受的结果
- 2 回答
- 0 关注
- 131 浏览
添加回答
举报