-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexigenciasLegais.php
124 lines (100 loc) · 3.4 KB
/
exigenciasLegais.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
122
123
<!DOCTYPE html>
<meta charset="utf-8"/>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/site.css">
<link rel="stylesheet" type="text/css" href="css/menuadm.css">
<link rel="stylesheet" type="text/css" href="css/form.css">
<link rel="stylesheet" type="text/css" href="css/buttons.css">
<title>Exigências Legais</title>
</head>
<body>
<div id="site">
<div id="menu">
<header id="headeradm">
<h4>Exigências Legais</h4>
<a href="index.php"><input id="btn_logout" type="button" value="Voltar"></a>
</header>
</div>
<div style="min-height: calc(100vh - 70px);">
<main>
<section id="sobrenos">
<?php
session_start();
require_once("DBConnection.php");
$consulta_sql = "SELECT exij_id FROM tb_exij";
$result = mysqli_query($conn, $consulta_sql);
$_qtde_total_registros_bd = mysqli_num_rows($result);//pega o numero total de linhas
$qtde_registros_por_pag = 4;
//definir a qtde de paginas
$qtde_paginas = ceil($_qtde_total_registros_bd / $qtde_registros_por_pag);
//verificar qual a pagina atual
$pagina_atual = isset($_GET['pagina_atual'])? filter_input(INPUT_GET, 'pagina_atual', FILTER_SANITIZE_NUMBER_INT): 1;
//definir inicio da nova consulta no bd, comforme a pagina atual
$inicio_consulta = ($qtde_registros_por_pag * $pagina_atual) - $qtde_registros_por_pag;
$consulta_sql = "SELECT
exij_id,
exij_tit,
exij_desc,
exij_font,
DATE_FORMAT(exij_data, '%d/%m/%Y') AS exij_data
FROM
tb_exij
ORDER BY
exij_id DESC
LIMIT $inicio_consulta, $qtde_registros_por_pag";
$result_consulta_sql = mysqli_query($conn, $consulta_sql);
$qtde_parcial_registros_bd = mysqli_num_rows($result_consulta_sql);
?>
<div id="div_scroll">
<?php while($registro = mysqli_fetch_array($result_consulta_sql, MYSQLI_BOTH)){?>
<div id="div_noti">
<div id="txt_exig">
<h2><b><?php echo $registro['exij_tit']?></b></h2>
<p><?php echo $registro['exij_desc']?></p>
<h6 id="publicado_em">Fonte: <?php echo $registro['exij_font']?> </h6>
<h6 id="publicado_em">Data: <?php echo $registro['exij_data']?> </h6>
</div>
</div>
<?php } ?>
</div>
<?php
if($pagina_atual > 1){ ?>
<a class="tirar_sublinhado" href="exigenciasLegais.php?pagina_atual=<?php echo ($pagina_atual - 1)?>">◄</a>
<?php }
for($link = $pagina_atual - 3, $limite_links = $link + 6;
$link <= $limite_links; $link++){
if($link < 1)
{
$link = 1;
$limite_links = 7;
}
if($limite_links > $qtde_paginas)
{
$limite_links = $qtde_paginas;
$link = $limite_links - 6;
}
if($link < 1)
{
$link = 1;
$limite_links = $qtde_paginas;
}
if($link == $pagina_atual)
{
?> <a class="tirar_sublinhado" id="destaque" href="#"><?php echo "<b>$link</b>"; ?></a>
<?php
}else{
?>
<a class="tirar_sublinhado" href="exigenciasLegais.php?pagina_atual=<?php echo $link ?>"><?php echo $link;?></a>
<?php }
}
if($pagina_atual != $qtde_paginas){ ?>
<a class="tirar_sublinhado" href="exigenciasLegais.php?pagina_atual=<?php echo ($pagina_atual + 1)?>">►</a>
<?php } ?>
</section>
</main>
</div>
<?php require_once("footer.php"); ?>
</div>
</body>
</html>