我想水平打印班次,垂直打印名称/ID。我有一个这样的出勤表=>>。出席表:
我想shift
以此表格式 html 表结构打印值:
<?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'";
$cnt=1;
$query = mysqli_query($conn, $qry);
foreach ($query as $q) {
$sid = $q['empid'];
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++) {
$qry2 = "SELECT * FROM `attendance` WHERE `empid`='$sid' AND `month`='$month' AND `date`='$i'";
$re2 = mysqli_query($conn, $qry2);
echo "<td>";
foreach ($re2 as $value => $q) {
$dt = $q['date'];
$s = $q['shift'];
if ($i == $dt) {
echo $s;
echo "</td>";
}else{
echo "<td>x</td>";
}
}
}
echo "</tr>";
}
echo "</table>";
?>
白衣染霜花
慕姐8265434