-
Notifications
You must be signed in to change notification settings - Fork 0
/
mark.php
38 lines (35 loc) · 996 Bytes
/
mark.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
<?php
echo "<div class='post'>";
$sql = "SELECT * FROM post WHERE id=:id";
$STH = $DBH->prepare($sql);
$STH->bindValue(':id',$id);
$STH->execute();
$row = $STH->fetch();
$count = (int)$row['count'];
$sum = (int)$row['sum'];
if($count > 0 ){
$rating = $sum / $count;
echo t($lang,'mark').$rating.t($lang,'users').$count;
}else{
echo t($lang,'not_voted');
}
if($_SESSION['ent'] === 2){
// чи голосував
$sql = "SELECT COUNT(*) FROM vote WHERE user_id=:user_id AND post_id=:post_id";
$STH = $DBH->prepare($sql);
$STH->bindValue(':user_id',$_SESSION['profil_id']);
$STH->bindValue(':post_id',$id);
$STH->execute();
$row = $STH->fetch();
//echo $row[0];exit;
if ($row[0] == 0){
include('form_vote.html');
}else{
echo '<a href=delete_mark.php?id='.$id.'>'.t($lang,'delete').'</a><p>';
}
if (in_array('admin',$_SESSION['roles'])){
echo '<p><a class="button" href=delete_all_mark.php?id='.$id.'>'.t($lang,'delete').'</a><p>';
}
}
echo "</div>";
?>