0
In the old method I used this way too much to insert or delete a series lines coming from an array. note that the variables are inside conchetes {$x} already using the PREPARE method msqli I can’t make it work
exemplo
$query = mysql_query ("INSERT INTO user
(nome,tel,email)VALUES('{$nome}','{$tel}',{$email}')", $conexao) or die( mysql_error());
or
if (isset($_POST['checkbox'])) {
foreach ($_POST['checkbox'] as $id) {
$del = "DELETE FROM user WHERE id = '{$id}' LIMIT 1";
$resultado2 = mysql_query($del) or die ("Falha ao Excluir Registro Os"); }}
How to make this delete for example work
if (isset($_POST['checkbox'])) {
foreach ($_POST['checkbox'] as $valor) {
// aqui você faz a parte da exclusão
$bd = new MySQLiConnection();
$stmt = $bd->prepare("DELETE FROM incluidos2 WHERE id=? ");
$stmt->bind_param('i', $valor);
$stmt->execute();
$stmt->close();
}}
If it goes like this it should work:
$stmt->bind_param('i', $valor);
– rray
That was soft my time to put here more independent of that does not work
– Fabio Henrique
See if this shows any error:
if(!$stmt->execute()){ print_r($bd->error);}
– rray