-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome.php
More file actions
180 lines (166 loc) · 4.3 KB
/
home.php
File metadata and controls
180 lines (166 loc) · 4.3 KB
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta name="viewport" content="width=1124">
<title>Voting System</title>
</head>
<style>
.custom-menu {
z-index: 1000;
position: absolute;
background-color: #ffffff;
border: 1px solid #0000001c;
border-radius: 5px;
padding: 18px;
min-width: 13vw;
}
a.custom-menu-list {
width: 100%;
display: flex;
color: white;
font-weight: 600;
font-size: 1em;
padding: 1px 11px;
}
span.card-icon {
position: absolute;
font-size: 3em;
bottom: .2em;
color: white;
}
.file-item{
cursor: pointer;
}
a.custom-menu-list:hover,.file-item:hover,.file-item.active {
background: #80808024;
}
table th,td{
/*border-left:1px solid gray;*/
}
a.custom-menu-list span.icon{
width:1em;
margin-right: 5px
}
.candidate {
margin: auto;
width: 23vw;
padding: 0 15px;
border-radius: 20px;
margin-bottom: 1em;
display: flex;
border: 3px solid #00000008;
background: #8080801a;
}
.candidate_name {
margin: 8px;
margin-left: 5.4em;
margin-right: 3em;
width: 100%;
}
.img-field {
display: flex;
height: 4vh;
width: 4.7vw;
padding: 1.7em;
background: #80808047;
border-radius: 50%;
position: absolute;
left: -.7em;
top: -.7em;
}
.candidate img {
height: 100%;
width: 100%;
margin: auto;
border-radius: 50%;
}
.vote-field {
position: absolute;
right: 0;
bottom: -.4em;
}
</style>
<div class="containe-fluid">
<?php include('db_connect.php') ;
$voting = $conn->query("SELECT * FROM voting_list where is_default = 1 ");
foreach ($voting->fetch_array() as $key => $value) {
$$key = $value;
}
$votes = $conn->query("SELECT * FROM votes where voting_id = $id ");
$v_arr = array();
while($row=$votes->fetch_assoc()){
if(!isset($v_arr[$row['voting_opt_id']]))
$v_arr[$row['voting_opt_id']] = 0;
$v_arr[$row['voting_opt_id']] += 1;
}
$opts = $conn->query("SELECT * FROM voting_opt where voting_id=".$id);
$opt_arr = array();
while($row=$opts->fetch_assoc()){
$opt_arr[$row['category_id']][] = $row;
}
?>
<div class="row">
<div class="col-lg-12">
<div class="card col-md-4 offset-2 bg-info float-left">
<div class="card-body text-white">
<h4><b>Voters</b></h4>
<hr>
<span class="card-icon"><i class="fa fa-users"></i></span>
<h3 class="text-right"><b><?php echo $conn->query('SELECT * FROM users where type = 2 ')->num_rows ?></b></h3>
</div>
</div>
<div class="card col-md-4 offset-2 bg-primary ml-4 float-left">
<div class="card-body text-white">
<h4><b>Voted</b></h4>
<hr>
<span class="card-icon"><i class="fa fa-user-tie"></i></span>
<h3 class="text-right"><b><?php echo $conn->query('SELECT distinct(user_id) FROM votes where voting_id = '.$id)->num_rows ?></b></h3>
</div>
</div>
</div>
</div>
<div class="row mt-3 ml-3 mr-3">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<div class="text-center">
<h3><b><?php echo $title ?></b></h3>
<small><b><?php echo $description; ?></b></small>
</div>
<?php
$cats = $conn->query("SELECT * FROM category_list where id in (SELECT category_id from voting_opt where voting_id = '".$id."' )");
while($row = $cats->fetch_assoc()):
?>
<hr>
<div class="row mb-4">
<div class="col-md-12">
<div class="text-center">
<h3><b><?php echo $row['category'] ?></b></h3>
</div>
</div>
</div>
<div class="row mt-6">
<?php foreach ($opt_arr[$row['id']] as $candidate) {
?>
<div class="candidate" style="position: relative;">
<div class="img-field">
<img src="assets/img/<?php echo $candidate['image_path'] ?>" alt="">
</div>
<div class="candidate_name"><?php echo $candidate['opt_txt'] ?></div>
<div class="vote-field">
<span class="badge badge-success"><large><b><?php echo isset($v_arr[$candidate['id']]) ? number_format($v_arr[$candidate['id']]) : 0 ?></b></large></span>
</div>
</div>
<?php } ?>
</div>
<?php endwhile; ?>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
</script>