Complete Student attendence code by class school management system php html with demo
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="img/logo1.png" rel="icon"/>
<title>LZM Admin | Attendence Section</title>
<link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<!-- DataTables -->
<link rel="stylesheet" href="plugins/datatables-bs4/css/dataTables.bootstrap4.css">
<!-- Theme style -->
<link rel="stylesheet" href="dist/css/adminlte.min.css">
<!-- Google Font: Source Sans Pro -->
<link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">
<?php include "nav.php";
include('session.php');
include('connect.php');
?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="dashboard.php">Home</a></li>
<li class="breadcrumb-item active">Attendence Section</li>
</ol>
</div>
</div>
</div><!-- /.container-fluid -->
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3 class="card-title">Attendence Section</h3>
<br />
<form method="post">
<div class="container">
<div class="row">
<div class="col-3">
<select class="form-control" name="class" style="width:200px">
<option value="" disabled selected>Choose Class</option>
<option value="NURSERY">NURSERY</option>
<option value="PREP">PREP</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
<option value="4">Four</option>
<option value="5">Five</option>
<option value="6">Six</option>
<option value="7">Seven</option>
<option value="8">Eight</option>
<option value="9">Nine</option>
<option value="10">Ten</option>
</select>
</div>
<div class="col-1">
<input type="submit" value="Click on it" class="btn btn-warning"/>
</div>
</div>
</div>
</form>
<?php
$class=$_POST['class'];
$date = date("d-m-Y");
echo '<p align="center"><b>Today : </b>'.$date.'</p>';
echo '<p align="center"><b>Class : </b>'.$class.'</p>';
?>
</div>
<!-- /.card-header -->
<div class="card-body">
<?php
$name="";
$reg="";
$con= mysqli_query($con, "select * from tbl_students where class='$class'");
$counter=0;
?>
<!--<button type="button" class="btn btn-primary">
<i class="fas fa-download"></i> Export to Excel
</button></p>-->
<form action="attd.php?class=<?php echo $class; ?>" method="post">
<table id="" class="table table-bordered table-striped" style="font-size:16px">
<thead>
<tr style="background-color:#009900; color:#FFFFFF">
<th>S.No</th>
<th>Reg No</th>
<th>Student Name</th>
<th>Present</th>
<th>Absent</th>
</tr>
</thead>
<tbody>
<?php
while($row= mysqli_fetch_array($con))
{
$reg=$row['reg_no'];
$name=$row['name'];
$phone=$row['mobile_no'];
?>
<tr>
<td><?php echo ++$counter; ?></td>
<td><?php echo $reg; ?></td>
<td><?php echo $name; ?></td>
<td><input type="radio" value="present" name="<?php echo $reg; ?>" /></td>
<td><input type="radio" value="absent" name="<?php echo $reg; ?>" /></td>
<input type="hidden" name="roll[]" value="<?php echo $reg; ?>" />
<input type="hidden" name="name[]" value="<?php echo $name; ?>" />
<input type="hidden" name="phone[]" value="<?php echo $phone; ?>" />
</tr>
<?php
}
?>
</tbody>
<tfoot>
</table>
<!-- <i class="fas fa-cloud-download-alt"></i>-->
<p align="right"><input type="submit" value="Save Attendence" class="btn btn-success"/></p>
</form>
</div>
<!-- /.card-body -->
</div>
<!-- /.card -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
<footer class="main-footer">
<div class="float-right d-none d-sm-block">
</div>
<strong>Copyright © 2021-22 <a href="#">LZM School</a>.</strong>
All rights reserved.
</footer>
<!-- Control Sidebar -->
<aside class="control-sidebar control-sidebar-dark">
<!-- Control sidebar content goes here -->
</aside>
<!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->
<!-- jQuery -->
<script src="plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- DataTables -->
<script src="plugins/datatables/jquery.dataTables.js"></script>
<script src="plugins/datatables-bs4/js/dataTables.bootstrap4.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
<!-- page script -->
<script>
$(function () {
$("#example1").DataTable();
$('#example2').DataTable({
"paging": true,
"lengthChange": false,
"searching": false,
"ordering": true,
"info": true,
"autoWidth": false,
});
});
</script>
<script>
$("#btnExport").click(function(){
var $table = $("#tblExportGrid");
ExportHTMLTableToExcel($table);
});
function ExportHTMLTableToExcel($table) {
var tab_text = ""
var final_text = "";
var filename = $table.attr('export-excel-filename'); // attribute to be
// applied on Table tag
filename = isNullOrUndefinedWithEmpty(filename)? "Excel Document" : filename;
var index = $table.find("tbody tr").length;
if (Number(index) > 0) {
$.each($table, function (index, item) {
var element = $(item);
var headertext = $("#" + element[0].id).closest
(":has(label.HeaderLabel)").find('label').text().trim();
if (headertext == "") {
tab_text = "<table border='2px'><tr>";
}
else {
tab_text = "<table border='2px'><tr> " + headertext + "</tr><tr>";
}
// Create column header
element.find("thead tr th").each(function () {
if (!$(this).hasClass("NoExport"))
tab_text = tab_text + "<td bgcolor='#87AFC6'>" +
$(this)[0].innerHTML + "</td>";
});
//Close column header
tab_text = tab_text + "</tr>";
// Create body column
element.find(" tbody tr").each(function () {
tab_text = tab_text + "<tr>";
$(this).find("td").each(function () {
if ($(this).hasClass("ExportLabelTD"))
{
var value = $(this).html();
tab_text = tab_text + "<th>" + value + "</th>";
}
else {
$(this).find("input,select").each(function () {
var value = "";
if ($(this).prop("type") == 'select-one') {
value = $('option:selected', this).text();
} else {
value = $(this).val();
}
if (!$(this).closest("td").hasClass("NoExport") &&
!$(this).hasClass("NoExport")) { // NoExport is used for TD
// or tan input tag that not needs to be exported
tab_text = tab_text + "<th>" + value + "</th>";
}
});
}
});
tab_text = tab_text + "</tr>";
});
// Create colum footer
element.find("tfoot tr td").each(function () {
var colspan = $(this).attr("colspan");
var rowspan = $(this).attr("rowspan");
colspan = colspan == undefined ? 1 : colspan;
rowspan = rowspan == undefined ? 1 : rowspan;
if ($(this).hasClass("NoExport")) {
tab_text = tab_text + "";
}
else if ($(this).hasClass("ExportValueTD")) // Footer class that needs
// to be no td that have input tags
{
$(this).find("input,select").each(function () {
var value = "";
if ($(this).prop("type") == 'select-one') {
value = $('option:selected', this).text();
} else {
value = $(this).val();
}
if (!$(this).closest("td").hasClass("NoExport") &&
!$(this).hasClass("NoExport")) {
tab_text = tab_text + "<td colspan=" + colspan + "
rowspan=" + rowspan + ">" + value + "</th>";
}
});
}
else
tab_text = tab_text + "<td colspan=" + colspan + "
rowspan=" + rowspan + ">" + $(this).html() + "</td>";
});
tab_text = tab_text + "<tr></tr></table>";
if (index == 0) {
final_text = tab_text;
}
else {
final_text = final_text + tab_text;
}
});
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0 || !!navigator.userAgent.match
(/Trident.*rv\:11\./)) // If Internet Explorer
{
txtArea1 = window.open();
txtArea1.document.open("txt/html", "replace");
txtArea1.document.write(final_text);
txtArea1.document.close();
txtArea1.focus();
sa = txtArea1.document.execCommand("SaveAs", true, filename+".xls");
return (sa);
}
else //other browser not tested on IE 11
{
//sa = window.open('data:application/vnd.ms-excel,' +
// encodeURIComponent(final_text));
var anchor = document.createElement('a');
anchor.setAttribute('href', 'data:application/vnd.ms-excel,' +
encodeURIComponent(final_text));
anchor.setAttribute('download', filename);
anchor.style.display = 'none';
document.body.appendChild(anchor);
anchor.click();
document.body.removeChild(anchor);
}
}
}
function isNullOrUndefinedWithEmpty(text){
if(text==undefined)
return true;
else if(text == null)
return true;
else if(text == null)
return true;
else
false;
}
</script>
</body>
</html>
demo
ReplyDeletehttps://youtu.be/sS8b1JEIuf8