forked from lukasdev/star-rating-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle.php
40 lines (36 loc) · 1.1 KB
/
single.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
<?php
include_once "conexao.php";
?>
<html lang="pt-BR">
<head>
<meta charset=UTF-8>
<title>Artigo Single</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/avaliations.js"></script>
</head>
<body>
<?php
$id = (int)$_GET['id'];
$pegaArtigo = $pdo->prepare("SELECT * FROM `artigos` WHERE id = ?");
$pegaArtigo->execute(array($id));
while($artigo = $pegaArtigo->fetchObject()){
$calculo = ($artigo->pontos == 0) ? 0 : round(($artigo->pontos/$artigo->votos), 1);
?>
<h1><?php echo utf8_encode($artigo->titulo);?> - <a href="index.php">Voltar</a></h1>
<span class="ratingAverage" data-average="<?php echo $calculo;?>"></span>
<span class="article" data-id="<?php echo $id;?>"></span>
<div class="barra">
<span class="bg"></span>
<span class="stars">
<?php for($i=1; $i<=5; $i++):?>
<span class="star" data-vote="<?php echo $i;?>">
<span class="starAbsolute"></span>
</span>
<?php
endfor;
echo '</span></div><p class="votos"><span>'.$artigo->votos.'</span> votos</p>';
}
?>
</body>
</html>