How to Delete Record Data using PHP Ajax | Design CSS
Step 1: database
CREATE TABLE `tbl_employee` (
`id` int(11) NOT NULL,
`name` varchar(50) NOT NULL,
`address` text NOT NULL,
`gender` varchar(10) NOT NULL,
`designation` varchar(100) NOT NULL,
`age` int(11) NOT NULL,
`image` varchar(100) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `tbl_employee` (
`id` int(11) NOT NULL, `name` varchar(50) NOT NULL, `address` text NOT NULL, `gender` varchar(10) NOT NULL, `designation` varchar(100) NOT NULL, `age` int(11) NOT NULL, `image` varchar(100) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; |
Step 2: connection.php
<?php
$servername = 'localhost';
$username = 'root';
$password = '';
$dbname = 'employee';
$conn = mysqli_connect($servername, $username, $password, "$dbname");
if($conn === false)
{
die("ERROR: Could not connect. " .mysqli_connect_error());
}
<?php $servername = 'localhost'; $username = 'root'; $password = ''; $dbname = 'employee'; $conn = mysqli_connect($servername, $username, $password, "$dbname"); if($conn === false) { die("ERROR: Could not connect. " .mysqli_connect_error()); } |
Step 2.1: delete.php
<?php
include 'connect_db.php';
//delete.php
if(isset($_POST["id"]))
{
foreach($_POST["id"] as $id)
{
$query = "DELETE FROM tbl_employee WHERE id = '".$id."'";
mysqli_query($conn, $query);
}
}
?>
<?php include 'connect_db.php'; //delete.php if(isset($_POST["id"])) { foreach($_POST["id"] as $id) { $query = "DELETE FROM tbl_employee WHERE id = '".$id."'"; mysqli_query($conn, $query); } } ?> |
Step 3: fetch.php
<?php
//fetch.php
include 'connect_db.php';
if(isset($_POST["employee_id"]))
{
$query = "SELECT * FROM tbl_employee WHERE id = '".$_POST["employee_id"]."'";
$result = mysqli_query($conn, $query);
$row = mysqli_fetch_array($result);
echo json_encode($row);
}
?>
<?php
//fetch.php include 'connect_db.php'; if(isset($_POST["employee_id"])) { $query = "SELECT * FROM tbl_employee WHERE id = '".$_POST["employee_id"]."'"; $result = mysqli_query($conn, $query); $row = mysqli_fetch_array($result); echo json_encode($row); } ?> |
Step 4: index.php
<?php
include 'connect_db.php';
$query = "SELECT * FROM tbl_employee ORDER BY id DESC";
$result = mysqli_query($conn, $query);
?>
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap Modal</title>
<!-- Brarry Css js -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto|Varela+Round">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<!-- css add external -->
<link rel="stylesheet" href="styles.css">
</head>
<body>
<br /><br />
<div class="container">
<h3 align="center">Employees Insert Data</h3>
<div class="table-wrapper">
<div class="table-title">
<div class="row">
<div class="col-sm-6">
<h2>Manage <b>Employees</b></h2>
</div>
<div class="col-sm-6">
<button type="button" name="add" id="add" data-toggle="modal" data-target="#add_data_Modal" class="btn btn-warning">Add New Employee</button>
<a type="button" name="btn_delete"id="btn_delete" class="btn btn-danger" data-toggle="modal">Delete</a>
</div>
</div>
</div>
<br />
<div id="employee_table">
<table class="table table-striped table-hover">
<tr>
<th>
<span class="custom-checkbox">
<input type="checkbox" id="selectAll">
<label for="selectAll"></label>
</span>
</th>
<th>Employee Name</th>
<th>Address</th>
<th>Gender</th>
<th>Designation</th>
<th>Age</th>
<th>Edit</th>
</tr>
<?php
while($row = mysqli_fetch_array($result))
{
?>
<tr>
<td>
<span class="custom-checkbox">
<input type="checkbox" id="checkbox1" name="checkbox" value="<?php echo $row["id"]; ?>">
<label for="checkbox1"></label>
</span>
</td>
<td><?php echo $row["name"]; ?></td>
<td><?php echo $row["address"]; ?></td>
<td><?php echo $row["gender"]; ?></td>
<td><?php echo $row["designation"]; ?></td>
<td><?php echo $row["age"]; ?></td>
<td><input type="button" name="edit" value="Edit" id="<?php echo $row["id"]; ?>" class="btn btn-info btn-xs edit_data" /></td>
</tr>
<?php
}
?>
</table>
<div class="clearfix">
<div class="hint-text">Showing <b>5</b> out of <b>100</b> entries</div>
<ul class="pagination">
<li class="page-item disabled"><a href="#">Previous</a></li>
<li class="page-item"><a href="#" class="page-link">1</a></li>
<li class="page-item"><a href="#" class="page-link">2</a></li>
<li class="page-item active"><a href="#" class="page-link">3</a></li>
<li class="page-item"><a href="#" class="page-link">4</a></li>
<li class="page-item"><a href="#" class="page-link">5</a></li>
<li class="page-item"><a href="#" class="page-link">Next</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<div id="dataModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Employee Details</h4>
</div>
<div class="modal-body" id="employee_detail">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="add_data_Modal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Insert and Edit</h4>
</div>
<div class="modal-body">
<form method="post" id="insert_form">
<label>Enter Employee Name</label>
<input type="text" name="name" id="name" class="form-control" />
<br />
<label>Enter Employee Address</label>
<textarea name="address" id="address" class="form-control"></textarea>
<br />
<label>Select Gender</label>
<select name="gender" id="gender" class="form-control">
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
<br />
<label>Enter Designation</label>
<input type="text" name="designation" id="designation" class="form-control" />
<br />
<label>Enter Age</label>
<input type="text" name="age" id="age" class="form-control" />
<br />
<input type="hidden" name="employee_id" id="employee_id" />
<input type="submit" name="insert" id="insert" value="Insert" class="btn btn-success" />
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Delete Modal HTML -->
<div id="deleteEmployeeModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<form>
<div class="modal-header">
<h4 class="modal-title">Delete Employee</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<p>Are you sure you want to delete these Records?</p>
<p class="text-warning"><small>This action cannot be undone.</small></p>
</div>
<div class="modal-footer">
<input type="button" class="btn btn-default" data-dismiss="modal" value="Cancel">
<input type="submit" class="btn btn-danger" value="Delete">
</div>
</form>
</div>
</div>
</div>
<script>
$(document).ready(function()
{
if(confirm("Are you sure you want to delete this?"))
{
var [i] = [];
$(':checkbox:checked').each(function(i)
{
id[i] = $(this).val();
});
if(id.length===0)
{
alert("Please Select atleaset one checkbox");
}
else
{
$.ajax({
url:'delete.php',
method:'POST',
data:{id:id},
success:function()
{
for(var i=0;i<id.length;i++)
{
$('tr#'+id[i].css('background-color','#ccc'))
$('tr#'+id[i]).fadeOut('slow');
}
}
});
}
}
else
{
return false;
}
});
})
</script>
<script>
$(document).ready(function()
{
$('#btn_delete').click(function()
{
if(confirm("Are you sure you want to delete this?"))
{
var id = [];
$(':checkbox:checked').each(function(i)
{
id[i] = $(this).val();
});
if(id.length === 0) //tell you if the array is empty
{
alert("Please Select atleast one checkbox");
}
else
{
$.ajax({
url:'delete.php',
method:'POST',
data:{id:id},
success:function()
{
for(var i=0; i<id.length; i++)
{
$('tr#'+id[i]+'').css('background-color', '#ccc');
$('tr#'+id[i]+'').fadeOut('slow');
}
}
});
}
}
else
{
return false;
}
});
});
</script>
<script>
$(document).ready(function(){
$('#add').click(function(){
$('#insert').val("Insert");
$('#insert_form')[0].reset();
});
$(document).on('click', '.edit_data', function(){
var employee_id = $(this).attr("id");
$.ajax({
url:"fetch.php",
method:"POST",
data:{employee_id:employee_id},
dataType:"json",
success:function(data){
$('#name').val(data.name);
$('#address').val(data.address);
$('#gender').val(data.gender);
$('#designation').val(data.designation);
$('#age').val(data.age);
$('#employee_id').val(data.id);
$('#insert').val("Update");
$('#add_data_Modal').modal('show');
}
});
});
$('#insert_form').on("submit", function(event){
event.preventDefault();
if($('#name').val() == "")
{
alert("Name is required");
}
else if($('#address').val() == '')
{
alert("Address is required");
}
else if($('#designation').val() == '')
{
alert("Designation is required");
}
else if($('#age').val() == '')
{
alert("Age is required");
}
else
{
$.ajax({
url:"insert.php",
method:"POST",
data:$('#insert_form').serialize(),
beforeSend:function()
{
$('#insert').val("Inserting");
},
success:function(data)
{
$('#insert_form')[0].reset();
$('#add_data_Modal').modal('hide');
$('#employee_table').html(data);
}
});
}
});
});
</script>
<script>
$(document).ready(function()
{
setTimeout(function()
{
$('#message').hide();
},3000);
});
</script>
<script src="javascript.js"></script>
<?php include 'connect_db.php'; $query = "SELECT * FROM tbl_employee ORDER BY id DESC"; $result = mysqli_query($conn, $query); ?> <!DOCTYPE html> <html> <head> <title>Bootstrap Modal</title> <!-- Brarry Css js --> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto|Varela+Round"> <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <!-- css add external --> <link rel="stylesheet" href="styles.css"> </head> <body> <br /><br /> <div class="container"> <h3 align="center">Employees Insert Data</h3> <div class="table-wrapper"> <div class="table-title"> <div class="row"> <div class="col-sm-6"> <h2>Manage <b>Employees</b></h2> </div> <div class="col-sm-6"> <button type="button" name="add" id="add" data-toggle="modal" data-target="#add_data_Modal" class="btn btn-warning">Add New Employee</button> <a type="button" name="btn_delete"id="btn_delete" class="btn btn-danger" data-toggle="modal">Delete</a> </div> </div> </div> <br /> <div id="employee_table"> <table class="table table-striped table-hover"> <tr> <th> <span class="custom-checkbox"> <input type="checkbox" id="selectAll"> <label for="selectAll"></label> </span> </th> <th>Employee Name</th> <th>Address</th> <th>Gender</th> <th>Designation</th> <th>Age</th> <th>Edit</th> </tr> <?php while($row = mysqli_fetch_array($result)) { ?> <tr> <td> <span class="custom-checkbox"> <input type="checkbox" id="checkbox1" name="checkbox" value="<?php echo $row["id"]; ?>"> <label for="checkbox1"></label> </span> </td> <td><?php echo $row["name"]; ?></td> <td><?php echo $row["address"]; ?></td> <td><?php echo $row["gender"]; ?></td> <td><?php echo $row["designation"]; ?></td> <td><?php echo $row["age"]; ?></td> <td><input type="button" name="edit" value="Edit" id="<?php echo $row["id"]; ?>" class="btn btn-info btn-xs edit_data" /></td> </tr> <?php } ?> </table> <div class="clearfix"> <div class="hint-text">Showing <b>5</b> out of <b>100</b> entries</div> <ul class="pagination"> <li class="page-item disabled"><a href="#">Previous</a></li> <li class="page-item"><a href="#" class="page-link">1</a></li> <li class="page-item"><a href="#" class="page-link">2</a></li> <li class="page-item active"><a href="#" class="page-link">3</a></li> <li class="page-item"><a href="#" class="page-link">4</a></li> <li class="page-item"><a href="#" class="page-link">5</a></li> <li class="page-item"><a href="#" class="page-link">Next</a></li> </ul> </div> </div> </div> </div> </div> </body> </html> <div id="dataModal" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Employee Details</h4> </div> <div class="modal-body" id="employee_detail"> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div> </div> </div> <div id="add_data_Modal" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Insert and Edit</h4> </div> <div class="modal-body"> <form method="post" id="insert_form"> <label>Enter Employee Name</label> <input type="text" name="name" id="name" class="form-control" /> <br /> <label>Enter Employee Address</label> <textarea name="address" id="address" class="form-control"></textarea> <br /> <label>Select Gender</label> <select name="gender" id="gender" class="form-control"> <option value="Male">Male</option> <option value="Female">Female</option> </select> <br /> <label>Enter Designation</label> <input type="text" name="designation" id="designation" class="form-control" /> <br /> <label>Enter Age</label> <input type="text" name="age" id="age" class="form-control" /> <br /> <input type="hidden" name="employee_id" id="employee_id" /> <input type="submit" name="insert" id="insert" value="Insert" class="btn btn-success" /> </form> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div> </div> </div> <!-- Delete Modal HTML --> <div id="deleteEmployeeModal" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <form> <div class="modal-header"> <h4 class="modal-title">Delete Employee</h4> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> </div> <div class="modal-body"> <p>Are you sure you want to delete these Records?</p> <p class="text-warning"><small>This action cannot be undone.</small></p> </div> <div class="modal-footer"> <input type="button" class="btn btn-default" data-dismiss="modal" value="Cancel"> <input type="submit" class="btn btn-danger" value="Delete"> </div> </form> </div> </div> </div> <script> $(document).ready(function() { if(confirm("Are you sure you want to delete this?")) { var [i] = []; $(':checkbox:checked').each(function(i) { id[i] = $(this).val(); }); if(id.length===0) { alert("Please Select atleaset one checkbox"); } else { $.ajax({ url:'delete.php', method:'POST', data:{id:id}, success:function() { for(var i=0;i<id.length;i++) { $('tr#'+id[i].css('background-color','#ccc')) $('tr#'+id[i]).fadeOut('slow'); } } }); } } else { return false; } }); }) </script> <script> $(document).ready(function() { $('#btn_delete').click(function() { if(confirm("Are you sure you want to delete this?")) { var id = []; $(':checkbox:checked').each(function(i) { id[i] = $(this).val(); }); if(id.length === 0) //tell you if the array is empty { alert("Please Select atleast one checkbox"); } else { $.ajax({ url:'delete.php', method:'POST', data:{id:id}, success:function() { for(var i=0; i<id.length; i++) { $('tr#'+id[i]+'').css('background-color', '#ccc'); $('tr#'+id[i]+'').fadeOut('slow'); } } }); } } else { return false; } }); }); </script> <script> $(document).ready(function(){ $('#add').click(function(){ $('#insert').val("Insert"); $('#insert_form')[0].reset(); }); $(document).on('click', '.edit_data', function(){ var employee_id = $(this).attr("id"); $.ajax({ url:"fetch.php", method:"POST", data:{employee_id:employee_id}, dataType:"json", success:function(data){ $('#name').val(data.name); $('#address').val(data.address); $('#gender').val(data.gender); $('#designation').val(data.designation); $('#age').val(data.age); $('#employee_id').val(data.id); $('#insert').val("Update"); $('#add_data_Modal').modal('show'); } }); }); $('#insert_form').on("submit", function(event){ event.preventDefault(); if($('#name').val() == "") { alert("Name is required"); } else if($('#address').val() == '') { alert("Address is required"); } else if($('#designation').val() == '') { alert("Designation is required"); } else if($('#age').val() == '') { alert("Age is required"); } else { $.ajax({ url:"insert.php", method:"POST", data:$('#insert_form').serialize(), beforeSend:function() { $('#insert').val("Inserting"); }, success:function(data) { $('#insert_form')[0].reset(); $('#add_data_Modal').modal('hide'); $('#employee_table').html(data); } }); } }); }); </script> <script> $(document).ready(function() { setTimeout(function() { $('#message').hide(); },3000); }); </script> <script src="javascript.js"></script> |
Step 5: insert.php
<?php
include 'connect_db.php';
if(!empty($_POST))
{
$output = '';
$message = '';
$name = mysqli_real_escape_string($conn, $_POST["name"]);
$address = mysqli_real_escape_string($conn, $_POST["address"]);
$gender = mysqli_real_escape_string($conn, $_POST["gender"]);
$designation = mysqli_real_escape_string($conn, $_POST["designation"]);
$age = mysqli_real_escape_string($conn, $_POST["age"]);
if($_POST["employee_id"] != '')
{
$query = "
UPDATE tbl_employee
SET name ='$name',
address ='$address',
gender ='$gender',
designation = '$designation',
age = '$age'
WHERE id='".$_POST["employee_id"]."'";
$message = 'Data Update has been Successfully!';
}
else
{
$query = "
INSERT INTO tbl_employee(name, address, gender, designation, age)
VALUES('$name', '$address', '$gender', '$designation', '$age');
";
$message = 'Data insert has been Successfully!';
}
if(mysqli_query($conn, $query))
{
$output .= '<label class="text-success">' . $message . '</label>';
$select_query = "SELECT * FROM tbl_employee ORDER BY id DESC";
$result = mysqli_query($conn, $select_query);
$output .= '
<table class="table table-striped table-hover">
<tr>
<th>Name</th>
<th>Address</th>
<th>Gender</th>
<th>Designation</th>
<th>Age</th>
<th>Edit</th>
<th>Delete</th>
</tr>
';
while($row = mysqli_fetch_array($result))
{
$output .= '
<tr>
<td>' . $row["name"] . '</td>
<td>' . $row["address"] . '</td>
<td>' . $row["gender"] . '</td>
<td>' . $row["age"] . '</td>
<td>' . $row["designation"] . '</td>
<td><input type="button" name="edit" value="Edit" id="'.$row["id"] .'" class="btn btn-info btn-xs edit_data" /></td>
<td><a href="#deleteEmployeeModal" class="delete" data-toggle="modal"><i class="material-icons" data-toggle="tooltip" title="Delete"></i></a></td>
</tr>
';
}
$output .= '</table>';
}
echo $output;
}
?>
<?php include 'connect_db.php'; if(!empty($_POST)) { $output = ''; $message = ''; $name = mysqli_real_escape_string($conn, $_POST["name"]); $address = mysqli_real_escape_string($conn, $_POST["address"]); $gender = mysqli_real_escape_string($conn, $_POST["gender"]); $designation = mysqli_real_escape_string($conn, $_POST["designation"]); $age = mysqli_real_escape_string($conn, $_POST["age"]); if($_POST["employee_id"] != '') { $query = " UPDATE tbl_employee SET name ='$name', address ='$address', gender ='$gender', designation = '$designation', age = '$age' WHERE id='".$_POST["employee_id"]."'"; $message = 'Data Update has been Successfully!'; } else { $query = " INSERT INTO tbl_employee(name, address, gender, designation, age) VALUES('$name', '$address', '$gender', '$designation', '$age'); "; $message = 'Data insert has been Successfully!'; } if(mysqli_query($conn, $query)) { $output .= '<label class="text-success">' . $message . '</label>'; $select_query = "SELECT * FROM tbl_employee ORDER BY id DESC"; $result = mysqli_query($conn, $select_query); $output .= ' <table class="table table-striped table-hover"> <tr> <th>Name</th> <th>Address</th> <th>Gender</th> <th>Designation</th> <th>Age</th> <th>Edit</th> <th>Delete</th> </tr> '; while($row = mysqli_fetch_array($result)) { $output .= ' <tr> <td>' . $row["name"] . '</td> <td>' . $row["address"] . '</td> <td>' . $row["gender"] . '</td> <td>' . $row["age"] . '</td> <td>' . $row["designation"] . '</td> <td><input type="button" name="edit" value="Edit" id="'.$row["id"] .'" class="btn btn-info btn-xs edit_data" /></td> <td><a href="#deleteEmployeeModal" class="delete" data-toggle="modal"><i class="material-icons" data-toggle="tooltip" title="Delete"></i></a></td> </tr> '; } $output .= '</table>'; } echo $output; } ?> |
Step 6: select.php
<?php
if(isset($_POST["employee_id"]))
{
$output = '';
$connect = mysqli_connect("localhost", "root", "", "testing");
$query = "SELECT * FROM tbl_employee WHERE id = '".$_POST["employee_id"]."'";
$result = mysqli_query($connect, $query);
$output .= '
<div class="table-responsive">
<table class="table table-striped table-hover">';
while($row = mysqli_fetch_array($result))
{
$output .= '
<tr>
<td><label>Name</label></td>
<td>'.$row["name"].'</td>
</tr>
<tr>
<td><label>Address</label></td>
<td>'.$row["address"].'</td>
</tr>
<tr>
<td><label>Gender</label></td>
<td>'.$row["gender"].'</td>
</tr>
<tr>
<td><label>Designation</label></td>
<td>'.$row["designation"].'</td>
</tr>
<tr>
<td><label>Age</label></td>
<td>'.$row["age"].' Year</td>
</tr>
';
}
$output .= '
</table>
</div>
';
echo $output;
}
?>
<?php
if(isset($_POST["employee_id"])) { $output = ''; $connect = mysqli_connect("localhost", "root", "", "testing"); $query = "SELECT * FROM tbl_employee WHERE id = '".$_POST["employee_id"]."'"; $result = mysqli_query($connect, $query); $output .= ' <div class="table-responsive"> <table class="table table-striped table-hover">'; while($row = mysqli_fetch_array($result)) { $output .= ' <tr> <td><label>Name</label></td> <td>'.$row["name"].'</td> </tr> <tr> <td><label>Address</label></td> <td>'.$row["address"].'</td> </tr> <tr> <td><label>Gender</label></td> <td>'.$row["gender"].'</td> </tr> <tr> <td><label>Designation</label></td> <td>'.$row["designation"].'</td> </tr> <tr> <td><label>Age</label></td> <td>'.$row["age"].' Year</td> </tr> '; } $output .= ' </table> </div> '; echo $output; } ?> |
Step 7: javascript.js
$(document).ready(function()
{
// Activate tooltip
$('[data-toggle="tooltip"]').tooltip();
// Select/Deselect checkboxes
var checkbox = $('table tbody input[type="checkbox"]');
$("#selectAll").click(function()
{
if(this.checked){
checkbox.each(function()
{
this.checked = true;
});
}
else
{
checkbox.each(function()
{
this.checked = false;
});
}
});
checkbox.click(function()
{
if(!this.checked)
{
$("#selectAll").prop("checked", false);
}
});
});
Step 8: styles.css
Step 8: styles.css
body {
color: #566787;
background: #f5f5f5;
font-family: 'Varela Round', sans-serif;
font-size: 13px;
}
.table-wrapper {
background: #fff;
padding: 20px 25px;
margin: 30px 0;
border-radius:1px;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.247);
}
.table-title {
padding-bottom: 15px;
background: linear-gradient(40deg, #2096ff, #05ffa3) !important;
color: #fff;
padding: 16px 30px;
margin: -20px -25px 10px;
border-radius: 1px 1px 0 0;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.247);
}
.table-title h2 {
margin: 5px 0 0;
font-size: 24px;
}
.table-title .btn-group {
float: right;
}
.table-title .btn {
color: #fff;
float: right;
font-size: 13px;
border: none;
min-width: 50px;
border-radius: 1px;
border: none;
outline: none !important;
margin-left: 10px;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.247);
}
.table-title .btn i {
float: left;
font-size: 21px;
margin-right: 5px;
}
.table-title .btn span {
float: left;
margin-top: 2px;
}
table.table tr th, table.table tr td {
border-color: #e9e9e9;
padding: 12px 15px;
vertical-align: middle;
}
table.table tr th:first-child {
width: 60px;
}
table.table tr th:last-child {
width: 100px;
}
table.table-striped tbody tr:nth-of-type(odd) {
background-color: #fcfcfc;
}
table.table-striped.table-hover tbody tr:hover {
background: #f5f5f5;
}
table.table th i {
font-size: 13px;
margin: 0 5px;
cursor: pointer;
}
table.table td:last-child i {
opacity: 0.9;
font-size: 22px;
margin: 0 5px;
}
table.table td a {
font-weight: bold;
color: #566787;
display: inline-block;
text-decoration: none;
outline: none !important;
}
table.table td a:hover {
color: #2196F3;
}
table.table td a.edit {
color: #FFC107;
}
table.table td a.delete {
color: #F44336;
}
table.table td i {
font-size: 19px;
}
table.table .avatar {
border-radius: 1px;
vertical-align: middle;
margin-right: 10px;
}
.pagination {
float: right;
margin: 0 0 5px;
}
.pagination li a {
border: none;
font-size: 13px;
min-width: 30px;
min-height: 30px;
color: #999;
margin: 0 2px;
line-height: 30px;
border-radius: 1px !important;
text-align: center;
padding: 0 6px;
}
.pagination li a:hover {
color: #666;
}
.pagination li.active a, .pagination li.active a.page-link {
background: #03A9F4;
}
.pagination li.active a:hover {
background: #0397d6;
}
.pagination li.disabled i {
color: #ccc;
}
.pagination li i {
font-size: 16px;
padding-top: 6px
}
.hint-text {
float: left;
margin-top: 10px;
font-size: 13px;
}
/* Custom checkbox */
.custom-checkbox {
position: relative;
}
.custom-checkbox input[type="checkbox"] {
opacity: 0;
position: absolute;
margin: 5px 0 0 3px;
z-index: 9;
}
.custom-checkbox label:before{
width: 18px;
height: 18px;
}
.custom-checkbox label:before {
content: '';
margin-right: 10px;
display: inline-block;
vertical-align: text-top;
background: white;
border: 1px solid #bbb;
border-radius: 1px;
box-sizing: border-box;
z-index: 2;
}
.custom-checkbox input[type="checkbox"]:checked + label:after {
content: '';
position: absolute;
left: 6px;
top: 3px;
width: 6px;
height: 11px;
border: solid #000;
border-width: 0 3px 3px 0;
transform: inherit;
z-index: 3;
transform: rotateZ(45deg);
}
.custom-checkbox input[type="checkbox"]:checked + label:before {
border-color: #03A9F4;
background: #03A9F4;
}
.custom-checkbox input[type="checkbox"]:checked + label:after {
border-color: #fff;
}
.custom-checkbox input[type="checkbox"]:disabled + label:before {
color: #b8b8b8;
cursor: auto;
box-shadow: none;
background: #ddd;
}
/* Modal styles */
.modal .modal-dialog {
max-width: 400px;
}
.modal .modal-header, .modal .modal-body, .modal .modal-footer {
padding: 20px 30px;
}
.modal .modal-content {
border-radius: 1px;
}
.modal .modal-footer {
background: #ecf0f1;
border-radius: 0 0 1px 1px;
}
.modal .modal-title {
display: inline-block;
}
.modal .form-control {
border-radius: 1px;
box-shadow: none;
border-color: #dddddd;
}
.modal textarea.form-control {
resize: vertical;
}
.modal .btn {
border-radius: 1px;
min-width: 100px;
}
.modal form label {
font-weight: normal;
}
body { color: #566787; background: #f5f5f5; font-family: 'Varela Round', sans-serif; font-size: 13px; } .table-wrapper { background: #fff; padding: 20px 25px; margin: 30px 0; border-radius:1px; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.247); } .table-title { padding-bottom: 15px; background: linear-gradient(40deg, #2096ff, #05ffa3) !important; color: #fff; padding: 16px 30px; margin: -20px -25px 10px; border-radius: 1px 1px 0 0; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.247); } .table-title h2 { margin: 5px 0 0; font-size: 24px; } .table-title .btn-group { float: right; } .table-title .btn { color: #fff; float: right; font-size: 13px; border: none; min-width: 50px; border-radius: 1px; border: none; outline: none !important; margin-left: 10px; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.247); } .table-title .btn i { float: left; font-size: 21px; margin-right: 5px; } .table-title .btn span { float: left; margin-top: 2px; } table.table tr th, table.table tr td { border-color: #e9e9e9; padding: 12px 15px; vertical-align: middle; } table.table tr th:first-child { width: 60px; } table.table tr th:last-child { width: 100px; } table.table-striped tbody tr:nth-of-type(odd) { background-color: #fcfcfc; } table.table-striped.table-hover tbody tr:hover { background: #f5f5f5; } table.table th i { font-size: 13px; margin: 0 5px; cursor: pointer; } table.table td:last-child i { opacity: 0.9; font-size: 22px; margin: 0 5px; } table.table td a { font-weight: bold; color: #566787; display: inline-block; text-decoration: none; outline: none !important; } table.table td a:hover { color: #2196F3; } table.table td a.edit { color: #FFC107; } table.table td a.delete { color: #F44336; } table.table td i { font-size: 19px; } table.table .avatar { border-radius: 1px; vertical-align: middle; margin-right: 10px; } .pagination { float: right; margin: 0 0 5px; } .pagination li a { border: none; font-size: 13px; min-width: 30px; min-height: 30px; color: #999; margin: 0 2px; line-height: 30px; border-radius: 1px !important; text-align: center; padding: 0 6px; } .pagination li a:hover { color: #666; } .pagination li.active a, .pagination li.active a.page-link { background: #03A9F4; } .pagination li.active a:hover { background: #0397d6; } .pagination li.disabled i { color: #ccc; } .pagination li i { font-size: 16px; padding-top: 6px } .hint-text { float: left; margin-top: 10px; font-size: 13px; } /* Custom checkbox */ .custom-checkbox { position: relative; } .custom-checkbox input[type="checkbox"] { opacity: 0; position: absolute; margin: 5px 0 0 3px; z-index: 9; } .custom-checkbox label:before{ width: 18px; height: 18px; } .custom-checkbox label:before { content: ''; margin-right: 10px; display: inline-block; vertical-align: text-top; background: white; border: 1px solid #bbb; border-radius: 1px; box-sizing: border-box; z-index: 2; } .custom-checkbox input[type="checkbox"]:checked + label:after { content: ''; position: absolute; left: 6px; top: 3px; width: 6px; height: 11px; border: solid #000; border-width: 0 3px 3px 0; transform: inherit; z-index: 3; transform: rotateZ(45deg); } .custom-checkbox input[type="checkbox"]:checked + label:before { border-color: #03A9F4; background: #03A9F4; } .custom-checkbox input[type="checkbox"]:checked + label:after { border-color: #fff; } .custom-checkbox input[type="checkbox"]:disabled + label:before { color: #b8b8b8; cursor: auto; box-shadow: none; background: #ddd; } /* Modal styles */ .modal .modal-dialog { max-width: 400px; } .modal .modal-header, .modal .modal-body, .modal .modal-footer { padding: 20px 30px; } .modal .modal-content { border-radius: 1px; } .modal .modal-footer { background: #ecf0f1; border-radius: 0 0 1px 1px; } .modal .modal-title { display: inline-block; } .modal .form-control { border-radius: 1px; box-shadow: none; border-color: #dddddd; } .modal textarea.form-control { resize: vertical; } .modal .btn { border-radius: 1px; min-width: 100px; } .modal form label { font-weight: normal; } |
0 Comments
CAN FEEDBACK
Emoji