-
Notifications
You must be signed in to change notification settings - Fork 0
/
crimes.php
123 lines (86 loc) · 3.38 KB
/
crimes.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
<?php include 'includes/connection.php'; ?>
<?php
//if (!isset($_SESSION['username'])) {
// header("Location: welcome.php");
//}
session_start();
?>
<?php include('includes/user_header.php') ?>
<!-- header section starts -->
<?php include('includes/user_navbar.php') ?>
<!-- features section starts -->
<section class="features margin-top" id="features">
<h1 class="heading"> <span style="color:#172260;">Crimes</span> </h1>
<?php if ($_SESSION["role"] == 'police') { ?>
<a class="btn btn-primary post-btn" href="crime_list.php">Crime List</a>
<?php } ?>
<a class="btn btn-primary post-btn" href="crime_create.php">Post A Crime</a>
<div class="box-container">
<?php
if (isset($_SESSION['id'])) {
$id = $_SESSION['id'];
// echo $id;
$sql = "SELECT * FROM crimes WHERE `user_id`='$id'";
$result = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_array($result)) { ?>
<div class="box">
<?php if ($row['image']) { ?>
<img src="<?php echo $row['image'] ?> " alt="">
<?php } else { ?>
<img src="image/fev.png" alt="">
<?php } ?>
<h3 style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap;">Title: <?php echo $row['title']; ?></h3>
<p>Location: <?php echo $row['location']; ?></p>
<p>Date: <?php echo $row['posted_at']; ?></p>
<a href="crime_details.php?id=<?php echo $row['id']; ?>" class="btn">Read More</a>
</div>
<?php }
} ?>
</div>
<br><br><br>
<div class="t1">
<table>
<tr>
<th>Title</th>
<th>Description</th>
<th>Date</th>
<th>Location</th>
</tr>
<tbody id="data"></tbody>
</table>
<script>
var ajax = new XMLHttpRequest();
ajax.open("GET", "ajax/crimesajax.php", true);
ajax.send();
ajax.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var data = JSON.parse(this.responseText);
console.log(data);
var html = "";
for (var a = 0; a < data.length; a++) {
var Title = data[a].title;
var Description = data[a].description;
var Date = data[a].posted_at;
var Location = data[a].location;
html += "<tr>";
html += "<td>" + Title + "</td>";
html += "<td>" + Description + "</td>";
html += "<td>" + Date + "</td>";
html += "<td>" + Location + "</td>";
html += "</tr>";
}
document.getElementById("data").innerHTML += html;
}
};
</script>
</div>
<br><br><br>
</section>
<!-- features section ends -->
<!-- footer section starts -->
<?php include('includes/user_footer.php') ?>
<script src="https://unpkg.com/swiper@7/swiper-bundle.min.js"></script>
<!-- custom js file link -->
<script src="js/script.js"></script>
</body>
</html>