Skip to content

Instantly share code, notes, and snippets.

@TiuTalk
Forked from silvarodrigo77/gist:4635771
Last active December 11, 2015 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TiuTalk/4635788 to your computer and use it in GitHub Desktop.
Save TiuTalk/4635788 to your computer and use it in GitHub Desktop.
<?php
// Conecta ao MySQL usando MySQLi
$MySQLi = new mysqli("localhost", "root", "Digue2013", "alternativa");
// Recebe os dados do formulário
# $chNFe = $_GET['chNFe']; // Não é usado?
$identidade = $_POST['Id'];
$COD_BARRAS = $_POST['COD_BARRAS'];
$DT_LANCAMENTO = $_POST['DT_LANCAMENTO'];
$DT_DEVOLUCAO = $_POST['DT_DEVOLUCAO'] ;
// Prepara uma query
$query = $MySQLi->prepare("UPDATE `nfe_entrada` SET `COD_BARRAS` = ?, `DT_LANCAMENTO` = ?, `DT_DEVOLUCAO` = ? WHERE `Id` = ?");
$updates = 0;
foreach ($identidade AS $key => $id) {
$query->bind_param("sssd", $COD_BARRAS[$key], $DT_LANCAMENTO[$key], $DT_DEVOLUCAO[$key], (int)$id);
if ($query->execute()) {
$updates += 1;
} else {
trigger_error($query->error);
}
$query->reset();
}
if ($updates > 0) {
echo ("<script>window.alert('Lançamento e devolução salvos com sucesso!');history.go(-1);</script>");
exit;
} else {
echo "<script>alert('Não foi possível salvar lançamento e devolução!');history.go(-1);</script>";
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment