-
Notifications
You must be signed in to change notification settings - Fork 154
/
poll-voters.php
121 lines (84 loc) · 4.13 KB
/
poll-voters.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
<?php
session_start();
require 'includes/dbh.inc.php';
define('TITLE',"Votes | KLiK");
if(!isset($_SESSION['userId']))
{
header("Location: login.php");
exit();
}
if (isset($_GET['poll']))
{
$pollid = $_GET['poll'];
}
else
{
header("Location: index.php");
exit();
}
include 'includes/HTML-head.php';
?>
</head>
<body>
<?php include 'includes/navbar.php'; ?>
<div class="container">
<div class="row">
<div class="col-sm-3">
<?php include 'includes/profile-card.php'; ?>
</div>
<div class="col-sm-9" id="user-section">
<img class="event-cover" src="img/pollpage-cover.png">
<div class="px-5 my-5">
<div class="px-5">
<?php
$sql = "select * from poll_options where poll_id=?";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql))
{
header("Location: ../poll-view.php?error=sqlerror");
exit();
}
else
{
mysqli_stmt_bind_param($stmt, "s", $pollid);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
while ($row = mysqli_fetch_assoc($result))
{
$sql2 = 'select u.uidUsers, u.idUsers, u.userImg '
. 'from poll_votes v join users u '
. 'on v.vote_by = u.idUsers '
. 'where poll_id = ? '
. 'and poll_option_id = ?';
$stmt = mysqli_stmt_init($conn);
mysqli_stmt_prepare($stmt, $sql2);
mysqli_stmt_bind_param($stmt, "ss", $pollid, $row['id']);
mysqli_stmt_execute($stmt);
$result2 = mysqli_stmt_get_result($stmt);
echo "<h4 class='text-muted'>".ucwords($row['name'])."</h4><br><br>";
$row2 = mysqli_fetch_assoc($result2);
if(empty($row2))
{
echo '<img class="empty-img" src="img/empty.png">
<br><br><hr><br>';
continue;
}
do
{
echo '<a href="profile.php?id='.$row2['idUsers'].'">
<h6><img class="voter-avatar" src="uploads/'.$row2['userImg'].'" >
'.ucwords($row2['uidUsers']).'<a>
</h6><br>';
}while ($row2 = mysqli_fetch_assoc($result2));
echo '<br><hr><br>';
}
}
?>
<a class="btn btn-primary btn-lg" href="poll.php?poll=<?php echo $pollid; ?>">Back To Poll</a>
</div>
</div>
</div>
</div>
</div> <!-- /container -->
<?php include 'includes/footer.php'; ?>
<?php include 'includes/HTML-footer.php'; ?>