Crud
Crud
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Information Management</title>
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/
bootstrap.min.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<!-- Custom CSS -->
<link rel="stylesheet" href="style.css">
</head>
<body>
</tbody>
</table>
<script>
$(document).ready(function() {
// Fetch student data and populate the table
function fetchStudents() {
$.ajax({
url: 'fetch_student.php', // URL to the PHP script
type: 'GET',
dataType: 'json',
success: function(data) {
// Clear existing table rows
var tableBody = $('.table tbody');
tableBody.empty();
// Delete Student
$(document).on('click', '.delete-btn', function() {
var studentId = $(this).data('stud_id');
</div>
</div>
</div>
<script>
$(document).ready(function() {
// Open Edit Modal and Populate Data
$(document).on('click', '.btn-warning', function() {
var row = $(this).closest('tr');
var studId = row.find('.delete-btn').data('stud_id');
var name = row.find('td:eq(0)').text();
var course = row.find('td:eq(1)').text();
var year = row.find('td:eq(2)').text();
var section = row.find('td:eq(3)').text();
var number = row.find('td:eq(4)').text();
var email = row.find('td:eq(5)').text();
$.ajax({
url: 'edit_student.php',
type: 'POST',
data: editData,
success: function(response) {
if (response.includes("Student Updated Successfully")) {
alert(response);
var modal =
bootstrap.Modal.getInstance(document.getElementById('editStudentModal'));
modal.hide();
fetchStudents();
} else {
alert("Error: " + response);
}
},
error: function(xhr, status, error) {
alert('An error occurred: ' + error);
}
});
});
$.ajax({
url: 'add_student.php',
type: 'POST',
data: studentData,
success: function(response) {
if (response.includes("Data Added Successfully")) {
alert(response);
$('#addStudentForm')[0].reset();
var modal =
bootstrap.Modal.getInstance(document.getElementById('addStudentModal'));
modal.hide();
fetchStudents();
} else {
alert("Error: " + response);
}
},
error: function(xhr, status, error) {
alert('An error occurred: ' + error);
}
});
});
});
</script>