为了账号安全,请及时绑定邮箱和手机立即绑定

以 HTML 表格格式打印出勤报告

以 HTML 表格格式打印出勤报告

PHP
慕慕森 2023-08-11 16:54:56
我想水平打印班次,垂直打印名称/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>";?>
查看完整描述

2 回答

?
白衣染霜花

TA贡献1796条经验 获得超10个赞

$qry ="SELECT * FROM emp";



查看完整回答
反对 回复 2023-08-11
?
慕姐8265434

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>";

作为接受的结果


查看完整回答
反对 回复 2023-08-11
  • 2 回答
  • 0 关注
  • 91 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信