-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbusca.php
64 lines (51 loc) · 1.61 KB
/
busca.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
<?php
require_once('./cabecalho.php');
include './conexao.php';
// Busca
if(isset($_GET['palavra'])){
$palavra=$_GET['palavra'];
$campo = nome_campo(1);
$sql = "select * from $table WHERE $campo LIKE :palavra order by id";
$sth = $pdo->prepare($sql);
$sth->bindValue(":palavra", $palavra."%");
$sth->execute();
$rows =$sth->fetchAll(PDO::FETCH_ASSOC);
}
print '<div class="container" align="center">';
print '<h4>Registro(s) encontrado(s)</h4>';
if(count($rows) > 0){
print '<div class="container" align="center">';
echo '<table class="table table-hover">';
echo "<tr>";
$num_campos = num_campos();
for($x=0;$x<$num_campos;$x++){
$campo = nome_campo($x);
?>
<th><?=ucfirst($campo)?></th>
<?php
}
print '<th colspan="2">Ação</th>';
echo "</tr>";
// Loop através dos registros recebidos
foreach ($rows as $row){
echo "<tr>";
for($x=0;$x<$num_campos;$x++){
$campo = nome_campo($x);
?>
<td><?=$row[$campo]?></td>
<?php
}
?>
<td><a href="atualizar.php?id=<?=$row['id']?>"><i class="glyphicon glyphicon-edit" title="Editar"></a></td>
<td><a href="excluir.php?id=<?=$row['id']?>"><i class="glyphicon glyphicon-remove-circle" title="Excluir"></a></td></tr>
<?php
echo "</tr>";
}
echo "</table>";
}else{
print '<h3>Nenhum Registro encontrado!</h3>';
}
?>
<input name="enviar" class="btn btn-warning" type="button" onclick="location='index.php'" value="Voltar">
</div>
<?php require_once('./cabecalho.php'); ?>