Use Insert or Delete using SQLI PREPARE with array

0

In the old method I used this way too low to insert or delete a series of lines from an array. note that the variables are inside brackets {$ x} already using the PREPARE method msqli I can not 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();
 }}
    
asked by anonymous 23.01.2018 / 03:39

0 answers