-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlistar.php
47 lines (44 loc) · 1.42 KB
/
listar.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
<div style="padding:10px; margin: 10px;border-radius: 20px; background-color: rgba(0, 0, 0, .15);backdrop-filter: blur(7px);color: #fff">
<h1>Listar Usuário</h1>
<?php
$sql = "SELECT * FROM user";
$res = $conn->query($sql);
$qtd = $res->num_rows;
if($qtd > 0){
print "<p>Encontrou <b>$qtd</b> resultado(s)</p>";
print "<table style='color: #fff'class='table table-bordered'>";
print "<tr>";
print "<th>#</th>";
print "<th>Nome</th>";
print "<th>E-mail</th>";
print "<th>Tipo</th>";
print "<th>Status</th>";
print "<th>Ações</th>";
print "</tr>";
while($row = $res->fetch_object()){
if($row->tipo=='1'){
$tipo = 'Administrador';
}else{
$tipo = 'Usuário Comum';
}
if($row->status=='1'){
$status = 'Ativo';
}else{
$status = 'Inativo';
}
print "<tr>";
print "<td>".$row->id."</td>";
print "<td>".$row->nome."</td>";
print "<td>".$row->email."</td>";
print "<td>".$tipo."</td>";
print "<td>".$status."</td>";
print "<td>
<button onclick=\"location.href='?page=editar&id=".$row->id."';\" class='btn btn-dark'>Editar</button>
<button onclick=\"if(confirm('Tem certeza que deseja excluir?')){location.href='?page=salvar&acao=excluir&id=".$row->id."';}else{false;}\" class='btn btn-danger'>Excluir</button>
</td>";
print "</tr>";
}
print "</table>";
}else{
print "Não encontrou resultados";
}