-
Notifications
You must be signed in to change notification settings - Fork 3
/
xml-buscar.php
93 lines (91 loc) · 3.77 KB
/
xml-buscar.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
<?php
$result = busca_xml($xml,"dados",$buscar,$opc,$order,$by);
$conta_result = count($result);
?>
<h2><span class="glyphicon glyphicon-phone"></span> CONTATOS CADASTRADOS</h2>
<hr />
<form class="form-inline" action="index.php" name="frmBuscar" method="get">
<div class="form-group">
<select name="opc" class="form-control">
<option value="nome"<?=$opc == "nome" ? " selected=\"selected\"" : ""?>>Nome</option>
<option value="tel"<?=$opc == "tel" ? " selected=\"selected\"" : ""?>>Telefone</option>
<option value="cel"<?=$opc == "cel" ? " selected=\"selected\"" : ""?>>Celular</option>
</select>
</div>
<div class="form-group">
<input type="text" name="buscar" value="<?=$buscar?>" id="idBuscar" class="form-control" />
</div>
<button type="submit" class="btn btn-primary">BUSCAR</button>
<input type="reset" name="limpar" class="btn" id="btnLimpar" value="LIMPAR">
</form>
<br>
<?php
// verifica se o array possui dados
if ($conta_result > 0){
?>
<table class="table table-bordered">
<thead>
<tr>
<th>Id</th>
<th><a href="index.php?opc=<?=$opc?>&buscar=<?=$buscar?>&id=<?=$id?>&action=buscar&order=@nome&by=<?=$byC?>">Nome</a></th>
<th>Telefone</th>
<th>Celular</th>
<th><a href="index.php?opc=<?=$opc?>&buscar=<?=$buscar?>&id=<?=$id?>&action=buscar&order=@email&by=<?=$byC?>">E-mail</a></th>
<th>Editar</th>
<th>Excluir</th>
</tr>
</thead>
<?php
// montando a tabela com os dados do arquivo xml
foreach ($result as $dados)
{
?>
<tbody>
<tr>
<td><?=$dados["id"]?></td>
<td><?=$dados["nome"]?></td>
<td><?=$dados["tel"]?></td>
<td><?=$dados["cel"]?></td>
<td><?=$dados["email"]?></td>
<td align="center">
<a href="index.php?action=edt&id=<?=$dados["id"]?>" id="btnEditar">
<span class="glyphicon glyphicon-edit"></span>
</a>
</td>
<td align="center">
<a href="index.php?action=del&id=<?=$dados["id"]?>" id="linkExcluir">
<span class="glyphicon glyphicon-remove"></span>
</a>
</td>
</tr>
</tbody>
<?php
}
?>
</table>
<?php
}
else
{
?>
<div class="alert alert-info"><strong>Aviso!</strong> Nenhum contato cadastrado no momento.</div>
<?php
}
?>
<div id="modalExclusao" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Confirmação de Exclusão</h4>
</div>
<div class="modal-body">
<p>Deseja realmente excluir o registro selecionado?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="btnExcluir">SIM</button>
<button type="button" class="btn btn-default" data-dismiss="modal">NÃO</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->