-
Notifications
You must be signed in to change notification settings - Fork 1
/
TOP10.php
55 lines (51 loc) · 1.68 KB
/
TOP10.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title</title>
<style>
body{
background-color: #fff3cd;
}
table, th, td, font{
border: 1px solid black;
width: 1100px;
background-color: lightblue;
font-family: Sans-Serif;
}
</style>
</head>
<body>
<center>
<H1>Top 10 Visitors</H1>
<table>
<tr>
<th>Handler</th>
<th>Name</th>
<th>Address</th>
<th>Apartment</th>
<th>Email</th>
<th>Phone</th>
<th>Time Visits</th>
</tr>
<?php
$conn = new mysqli('localhost', 'root', '', 'Visitor Management');
if ($conn->connect_error){
die("Connection failed: ". $conn-> connect_error);
}
$sql = "SELECT handler, name, address, apartment, email, phone, count(*) FROM visitor Group by visitor_id ORDER BY count(*) desc LIMIT 10";
$result_1 = $conn-> query($sql);
if ($result_1-> num_rows > 0){
while ($row = $result_1->fetch_assoc()){
echo "<tr><td>".$row["handler"]."</td><td>".$row["name"]."</td><td>".$row["address"]."</td><td>".$row["apartment"]."</td><td>".$row["email"]."</td><td>".$row["phone"]."</td><td>".$row["count(*)"]." Times</td></tr>";
}
echo "</table>";
}
else {
echo "0 result";
}
$conn-> close();
?>
</table>
</center>
</body>
</html>