0% found this document useful (0 votes)
6 views2 pages

Subject Management Interface

This document contains a PHP script that generates a user interface for managing subjects in a database. It includes a table displaying subject details such as code, name, description, and action buttons for editing or deleting subjects. Additionally, it features JavaScript functions to handle adding, editing, and deleting subjects through AJAX requests.

Uploaded by

Sora
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Subject Management Interface

This document contains a PHP script that generates a user interface for managing subjects in a database. It includes a table displaying subject details such as code, name, description, and action buttons for editing or deleting subjects. Additionally, it features JavaScript functions to handle adding, editing, and deleting subjects through AJAX requests.

Uploaded by

Sora
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

<?php include'db_connect.php' ?

>
<div class="col-lg-12">
<div class="card card-outline card-primary">
<div class="card-header">
<div class="card-tools">
<a class="btn btn-block btn-sm btn-default btn-flat border-
primary new_subject" href="javascript:void(0)"><i class="fa fa-plus"></i> Add
New</a>
</div>
</div>
<div class="card-body">
<table class="table tabe-hover table-bordered" id="list">
<colgroup>
<col width="10%">
<col width="20%">
<col width="20%">
<col width="30%">
<col width="20%">
</colgroup>
<thead>
<tr>
<th class="text-center">#</th>
<th>Code</th>
<th>Subjects</th>
<th>Description</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
$qry = $conn->query("SELECT * FROM subjects order by
unix_timestamp(date_created) desc ");
while($row= $qry->fetch_assoc()):
?>
<tr>
<th class="text-center"><?php echo $i++ ?></th>
<td><b><?php echo ucwords($row['subject_code'])
?></b></td>
<td><b><?php echo ucwords($row['subject']) ?
></b></td>
<td><p class=""><?php echo
$row['description'] ?></p></td>
<td class="text-center">
<div class="btn-group">
<a href="javascript:void(0)" data-id='<?php
echo $row['id'] ?>' class="btn btn-primary btn-flat manage_subject">
<i class="fas fa-edit"></i>
</a>
<button type="button" class="btn btn-danger
btn-flat delete_subject" data-id="<?php echo $row['id'] ?>">
<i class="fas fa-trash"></i>
</button>
</div>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$('#list').dataTable()
$('.new_subject').click(function(){
uni_modal("New Subject","manage_subject.php")
})
$('.manage_subject').click(function(){
uni_modal("Manage Subject","manage_subject.php?id="+$
(this).attr('data-id'))
})
$('.delete_subject').click(function(){
_conf("Are you sure to delete this Subject?","delete_subject",[$
(this).attr('data-id')])
})
})
function delete_subject($id){
start_load()
$.ajax({
url:'[Link]?action=delete_subject',
method:'POST',
data:{id:$id},
success:function(resp){
if(resp==1){
alert_toast("Data successfully deleted",'success')
setTimeout(function(){
[Link]()
},1500)

}
}
})
}
</script>

You might also like