-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
390 additions
and
432 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
require_once('./cabecalho.php'); | ||
require_once('./conexao.php'); | ||
|
||
// Receebr o id via GET do busca_resultados.php ou via POST deste arquivo | ||
if(isset($_GET['id'])){ | ||
$id=$_GET['id']; | ||
}else{ | ||
$id=$_POST['id']; | ||
} | ||
|
||
// Mostrar nome da Tabela | ||
print '<h3 align="center">'.ucfirst($table).'</h3>'; | ||
?> | ||
|
||
<!-- Mostrar form de atualização --> | ||
<div class="container" align="center"> | ||
<div class="row"> | ||
<div class="col-md-3"></div> | ||
<div class="col-md-6"> | ||
<form method="post" action="atualizar.php"> | ||
<table class="table table-bordered table-responsive table-hover"> | ||
|
||
<?php | ||
$sth = $pdo->prepare("SELECT * from $table WHERE id = :id"); | ||
$sth->bindValue(':id', $id, PDO::PARAM_STR); // No select e no delete basta um único bindValue | ||
$sth->execute(); | ||
|
||
$reg = $sth->fetch(PDO::FETCH_OBJ); | ||
|
||
$num_campos = num_campos(); | ||
|
||
for($x=1;$x<$num_campos;$x++){ | ||
$campo = nome_campo($x); | ||
?> | ||
<tr><td><b><?=ucfirst($campo)?></td><td><input type="text" name="<?=$campo?>" value="<?=$reg->$campo?>"></td></tr> | ||
<?php | ||
} | ||
?> | ||
<input name="id" type="hidden" value="<?=$id?>"> | ||
<tr><td></td><td><input name="enviar" class="btn btn-primary" type="submit" value="Editar"> | ||
<input name="enviar" class="btn btn-warning" type="button" onclick="location='index.php'" value="Voltar"></td></tr> | ||
</table> | ||
</form> | ||
</div> | ||
<div> | ||
</div> | ||
|
||
<?php | ||
require_once('./rodape.php'); | ||
require_once('./atualizarbd.php'); | ||
?> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
if(isset($_POST['enviar'])){ | ||
|
||
$set=''; | ||
$num_campos = num_campos(); | ||
|
||
for($x=0;$x<$num_campos;$x++){ | ||
$campo = nome_campo($x); | ||
// A linha abaixo gerará a linha: $nome = 'Nome do cliente'; | ||
$$campo = $_POST[$campo]; | ||
|
||
// Esta if gerará a variável $set contendo "$nome = :$nome, $email = :$email, ..."; | ||
if($x<$num_campos-1){ | ||
if($x==0) continue;// Evitar o id | ||
$set .= "$campo = :$campo,"; | ||
}else{ | ||
if($x==0) continue; | ||
$set .= "$campo = :$campo"; | ||
} | ||
} | ||
|
||
$sql = "UPDATE $table SET $set WHERE id = :id"; | ||
|
||
$sth = $pdo->prepare($sql); | ||
|
||
for($x=0;$x<$num_campos;$x++){ | ||
$campo = nome_campo($x); | ||
$sth->bindParam(":$campo", $_POST["$campo"], PDO::PARAM_STR); | ||
} | ||
|
||
if($sth->execute()){ | ||
print "<script>location='index.php';</script>"; | ||
}else{ | ||
print "Erro ao editar o registro!<br><br>"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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'); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.