I have my exclude employee but give these errors:
"Undefined index: id in C: \ wamp \ www \ SitePHP \ base \ deleteFuntionary.php on line 6"
"PDO :: exec () expects parameter 1 to be string, object given in C: \ wamp \ www \ SitePHP \ base \ deleteFuntionary.php on line 8".
Follow my code:
require_once '../base/conexao.php';
$id = $_GET['id'];
$delete = $PDO->query("DELETE FROM funcionario WHERE id = '$id' ");
$PDO->exec($delete);
if ($id){
echo "<script>alert('Registro de Funcionario deletado');location.href = 'listarFuncionario.php'; </script>";
}else{
echo "<script>alert('Ocorreu um erro no processo');location.href = 'listarFuncionario.php'; </script>";
}
function excluir(id){
if(confirm("Deseja excluir o registro?")){
location.href = 'excluirFuncionario.php';
}
}
<?php while($funcionario = $rs->fetch(PDO::FETCH_ASSOC)) { ?>
<tr>
<td align="center"><a href="excluirFuncionario.php" onkeyup="excluir(id)" onclick="excluir(<?php echo $funcionario['id'];?>)"><img src="../imagens/delete.png"></a></td>
</tr>
<?php }?>
</tbody>