-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresult.php
78 lines (74 loc) · 3.12 KB
/
result.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
<?php include("db.php"); ?>
<?php
$query = "SELECT * FROM nominees";
$result = mysqli_query($connection, $query);
if(!$result){
die("QUERY FAILED " . mysqli_error($connection));
}else{
while($row = mysqli_fetch_assoc($result)){
$nominees_name = $row['nominees_name'];
$count_query = "SELECT COUNT(*) FROM users WHERE user_responcef = '{$nominees_name}' or user_responcem = '{$nominees_name}'";
$count_query_result = mysqli_query($connection, $count_query);
if($count_query_result){
$count_row = mysqli_fetch_assoc($count_query_result);
$count = $count_row['COUNT(*)'];
$r=mysqli_query($connection, "UPDATE nominees SET vote_count = '{$count}' WHERE nominees_name = '{$nominees_name}'");
if(!$r){
die("F" . mysqli_error($connection));
}
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Results</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="box">
<table border='1' style="color:white;">
<tr>
<th>Male Representative</th>
<th>Vote Count</th>
</tr>
<?php
$selet_nominee_male = "SELECT * FROM nominees WHERE nominee_gender = 'male' ORDER BY vote_count DESC LIMIT 5";
$selet_nominee_fmale = "SELECT * FROM nominees WHERE nominee_gender = 'female' ORDER BY vote_count DESC LIMIT 5";
$res_male = mysqli_query($connection, $selet_nominee_male);
$res_fmale = mysqli_query($connection, $selet_nominee_fmale);
if($res_male && $res_fmale){
while($selet_nominee_rowm = mysqli_fetch_assoc($res_male)){
$nominees_namem = $selet_nominee_rowm['nominees_name'];
$vote_countm = $selet_nominee_rowm['vote_count'];
echo "<tr>";
echo "<td>$nominees_namem</td>";
echo "<td>$vote_countm</td>";
echo "</tr>";
}
?>
<tr>
<th>Female Representative</th>
<th>Vote Count</th>
</tr>
<?php
if(mysqli_num_rows($res_fmale)){
while($selet_nominee_rowf = mysqli_fetch_assoc($res_fmale)){
$nominees_namef = $selet_nominee_rowf['nominees_name'];
$vote_countf = $selet_nominee_rowf['vote_count'];
echo "<tr>";
echo "<td>$nominees_namef</td>";
echo "<td>$vote_countf</td>";
echo "</tr>";
}
}
}
?>
</table>
</div>
</body>
</html>