-
Notifications
You must be signed in to change notification settings - Fork 0
/
area_home.php
106 lines (88 loc) · 4.56 KB
/
area_home.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
<div id="roteiros">
<div id="introducao">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since type specimen book !!</p>
</div>
<?php
$numBotoesPag = 3;
$limit = 6;
$sql_roteirosTodos = "SELECT count(id) as total
FROM
roteiro
WHERE ativo=1";
$result_roteirosTodos = mysql_query($sql_roteirosTodos);
$linhatotal = mysql_fetch_array($result_roteirosTodos);
$total_num_rows = $linhatotal['total'];
$totalPaginas = ceil($total_num_rows / $limit);
$pag = (isset($_GET['pag']) && is_numeric($_GET['pag'])) ? $_GET['pag'] : 1;
if ($pag > $totalPaginas)
$pag = $totalPaginas;
$offset = (($pag - 1) * $limit);
$sql_roteirosPag = "SELECT id, titulo, imagem, descricao
FROM
roteiro
WHERE ativo=1
ORDER BY roteiro.data DESC limit $offset, $limit";
$result_roteirosPag = mysql_query($sql_roteirosPag);
?><a name="roteiros"></a><?php
if (@mysql_num_rows($result_roteirosPag)) {
?><div class="clearfix">
<ul id="roteiroBox" class="clearfix"><?php
while ($row = mysql_fetch_assoc($result_roteirosPag)) {
?>
<li class="roteiro esq borda">
<div style="background-image: url('<?php echo 'img/gd_' . $row['imagem']; ?>');" class="ultimosRoteiros"></div>
<div class="descricao">
<h3><?php echo utf8_encode($row['titulo']); ?></h3>
<?php echo limit_words(html_entity_decode(utf8_encode($row['descricao'])), 50); ?>
</div>
<div class="saibaMais">
<a href="index.php?area=destinos&roteiro=<?php echo $row['id']; ?>">Saiba mais</a>
</div>
</li>
<?php
}
?></ul>
</div>
<div id="paginas" class="clearfix">
<ul>
<?php if ($pag >= $numBotoesPag) { ?>
<li><a href="?pag=1#roteiros"><<</a></li>
<li><a href="?pag=<?php echo $pag - 1; ?>#roteiros"><</a></li>
<li><a href="?pag=<?php echo (($pag - $numBotoesPag) < 1) ? 1 : ($pag - $numBotoesPag); ?>#roteiros" class="reticencias">...</a></li>
<?php
}
if ($pag == 1) {
?>
<li><a href="?pag=<?php echo $pag; ?>#roteiros" class="paginaAtiva"><?php echo $pag; ?></a></li>
<?php if (($pag + 1) <= $totalPaginas) { ?>
<li><a href="?pag=<?php echo $pag + 1; ?>#roteiros"><?php echo $pag + 1; ?></a></li>
<?php } ?>
<?php if (($pag + 2) <= $totalPaginas) { ?>
<li><a href="?pag=<?php echo $pag + 2; ?>roteiros"><?php echo $pag + 2; ?></a></li>
<?php } ?>
<?php } else if ($pag > 1 && $pag < $totalPaginas) { ?>
<li><a href="?pag=<?php echo $pag - 1; ?>#roteiros"><?php echo $pag - 1; ?></a></li>
<li><a href="?pag=<?php echo $pag; ?>#roteiros" class="paginaAtiva"><?php echo $pag; ?></a></li>
<li><a href="?pag=<?php echo $pag + 1; ?>#roteiros"><?php echo $pag + 1; ?></a></li>
<?php } else if ($pag == $totalPaginas) { ?>
<?php if (($pag - 2) >= 1) { ?>
<li><a href="?pag=<?php echo $pag - 2; ?>#roteiros"><?php echo $pag - 2; ?></a></li>
<?php } ?>
<?php if (($pag - 1) >= 1) { ?>
<li><a href="?pag=<?php echo $pag - 1; ?>roteiros"><?php echo $pag - 1; ?></a></li>
<?php } ?>
<li><a href="?pag=<?php echo $pag; ?>#roteiros" class="paginaAtiva"><?php echo $pag; ?></a></li>
<?php
}
if ($pag <= ($totalPaginas - $numBotoesPag + 1)) {
?>
<li><a href="?pag=<?php echo (($pag + $numBotoesPag) > $totalPaginas) ? $totalPaginas : ($pag + $numBotoesPag); ?>#roteiros" class="reticencias">...</a></li>
<li><a href="?pag=<?php echo $pag + 1 ?>#roteiros">></a></li>
<li><a href="?pag=<?php echo $totalPaginas; ?>#roteiros">>></a></li>
<?php } ?>
</ul>
</div>
<?php
}
?>
</div>