我正在研究员工出勤系统,出勤工作正常,但现在的问题是,当我选择员工姓名以及开始和结束日期时,如何生成出勤报告?我完成所有我现在需要的HTML代码是可以使用我现在的HTML代码的PHP代码。请感谢您的帮助,提前谢谢。 下面是html代码。
<form class="form-horizontal" action="" method="post">
<div class="form-group">
<label class="col-sm-3 control-label"> Select Employee Name</label>
<div class="col-sm-4">
<select type="text" name="name" class="form-control" placeholder="Employee Full Name" required>
<option value="">Select Employee Name</option>
<?php
$get = mysql_query("SELECT employee_name FROM employee");
while($row = mysql_fetch_assoc($get)) {
?>
<option value = "<?php echo($row['employee_name'])?>" >
<?php echo($row['employee_name']) ?>
</option>
<?php
}
?>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"> Start Date</label>
<div class="col-sm-4">
<input type="text" name="Start_date" class="input-group date form-control" date="" data-date-format="yyyy-mm-dd" placeholder="0000-00-00" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">End Date</label>
<div class="col-sm-4">
<input type="text" name="end_date" class="input-group date form-control" date="" data-date-format="yyyy-mm-dd" placeholder="0000-00-00" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label"> </label>
<div class="col-sm-6">
<input type="submit" name="add" class="btn btn-sm btn-primary" value="Generate Report">
<div class="table-responsive">
<table class="table table-striped table-hover">
<tr>
<th>No</th>
<th> Employee Id</th>
<th>Employee Name</th>
<th>Date In</th>
<th>Time In</th>
<th>Late</th>
<th>Tools</th>
</tr>
</table>
</div>
</div>
</form>
答案 0 :(得分:0)
相应地更改您的查询,例如:
"SELECT employee_name FROM employee WHERE '".$date."' BETWEEN (start_date, end_date);"
或者您也可以使用>=
和<=
来比较日期
答案 1 :(得分:0)
只需添加一个打印按钮并为其提供ID。包含JS代码:
function printData()
{
var divToPrint=document.getElementById("printTable");
newWin= window.open("");
newWin.document.write(divToPrint.outerHTML);
newWin.print();
newWin.close();
}
$('button').on('click',function(){
printData();
})