-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathofficierMain.php
130 lines (114 loc) · 4.38 KB
/
officierMain.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
$servername = "localhost";
$username = "root";
$password = "";
$db="management_of_prison";
// Create connection
$conn = new mysqli($servername, $username, $password,$db);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT first_name,section_name,case_type,case_year,status from prisoner";
$result = mysqli_query($conn, $sql);
while($row = mysqli_fetch_assoc($result)) {
$result_array[] = $row;
}
mysqli_close($conn);
?>
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Main</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel='stylesheet prefetch' href='https://fonts.googleapis.com/css?family=Open+Sans:400,300'>
<link rel='stylesheet prefetch' href='https://fonts.googleapis.com/icon?family=Material+Icons'>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="resources/css/task_style.css">
<link rel="stylesheet" href="resources/css/login_style.css">
<link rel="stylesheet" href="resources/css/boostrap.css">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<style>
h2{margin-right : 1400px;}
.logo{margin-left: 10px;
margin-right: 10px;
margin-top: 10px;
margin-bottom: : 10px;
float: left;}
.pointer {cursor: pointer;}
</style>
</head>
<body>
<div class="header">
<div class="w3-container w3-black">
<img class="logo" src="resources/img/logo2.png" width="100" alt="image" height="70">
<div class="lining">
<ul b class="navUl">
<li class="navLi"><a href="Login.html"> LogOut</a></li>
<li class="navLi"><a href="addPrisoner.php"> Add Prinsoner</a></li>
</ul>
</div>
<h2>Prison Mangement</h2>
</div>
</div>
<div class="cont_centrar">
<table class="responstable">
<th>Id</th>
<th>Name</th>
<th>Section Name</th>
<th>Case Type</th>
<th>Case Year</th>
<th>Status</th>
<th>Action</th>
<?php
foreach($result_array as $row) { ?>
<tr>
<td><?=$row["prisoner_id"]?></td>
<td><?=$row["first_name"]?></td>
<td><?=$row["section_name"]?></td>
<td><?=$row["case_type"]?></td>
<td><?=$row["case_year"]?></td>
<td><?=$row["status"]?></td>
<td><span class='deleteMe btn-danger pointer' type="button" id="<?=$row["prisoner_id"]?>">Relise</span></td>
</tr>
<?php }
?>
</table>
</div>
<script>
$(document).ready(function(){
// Delete
$('.deleteMe').click(function(){
var el = this;
var delete_officer_id = this.id;
var deleteid =parseInt(delete_officer_id,10);
if(confirm('Are you sure you want to relise the prisoner?')){
// AJAX Request
$.ajax({
url: 'removePrisoner.php',
type: 'POST',
data: { id:deleteid },
success: function(response){
if(response == 1){
// Remove row from HTML Table
$(el).closest('tr').css('background','tomato');
$(el).closest('tr').fadeOut(800,function(){
$(this).remove();
//alert('Officer removed !!');
});
}else{
alert('Invalid Prisoner ID.');
}
}
});
}});
});
</script>
<script src="js/index.js"></script>
</body>
</html>