Note that there are some explanatory texts on larger screens.

plurals
  1. POI can't delete fields in a mysql database
    primarykey
    data
    text
    <p>I need to delete to generate a form to select in checkboxes which users I want to delete from the database. To search the users and generate the form I use this code:</p> <pre><code>&lt;?php $con = new mysqli('localhost', 'root', '', 'prueba'); $busqueda =""; $busqueda=$_POST['busqueda'] ; // funcion para convertir el contenido de un array en un string function makestring($array) { $outval = ''; if (is_array($array)) { foreach($array as $key=&gt;$value) { if(is_array($value)) { $outval = makestring($value); } else { $outval = $value; } } } return $outval; } if ($busqueda!=""){ $busca = mysqli_query($con, " SELECT usuario FROM usuarios WHERE usuario LIKE '%$busqueda%'"); echo "&lt;form action='borrar.php' method='post' enctype='multipart/form-data'&gt;"; while ($array= mysqli_fetch_array($busca)){ $user=makestring($array); echo"Usuario: &lt;input type='checkbox' name='borrar_usuario[]' value='$user' /&gt;$user&lt;br/&gt;"; } echo " &lt;input type='submit' name='boton' value='eliminar' /&gt;"; echo "&lt;/form&gt;"; } $all =$_POST['todos'] ; if ($all=='borrar_todos'){ $busca = mysqli_query($con, "select usuario from usuarios "); echo "&lt;form action='borrar.php' method='post' enctype='multipart/form-data'&gt;"; while ($f = mysqli_fetch_array($busca)){ $user=makestring($f); echo "Usuario: &lt;input type='checkbox' name='borrar_usuario[]' value='$user' /&gt;$user&lt;br/&gt;"; } echo " &lt;input type='submit' name='boton' value='eliminar' /&gt;"; echo "&lt;/form&gt;"; } ?&gt; </code></pre> <p>I use this code to collect the data from the forms with this code:</p> <pre><code>&lt;?php $con = new mysqli('localhost', 'root', '', 'prueba'); if(isset($_REQUEST["borrar_usuario"])) { $del_user = $_POST["borrar_usuario"]; $mensaje = "¿Está seguro que quiere eliminar el usuario &lt;b&gt;$row[usuarioNombre]&lt;/b&gt;?"; } // mostramos el mensage echo $mensaje; mysqli_query($con, "delete usuario, password, descripcion from usuarios where usuario in like '$del_user'"); echo "usuario borrado"; header('refresh: 3; url= exito.php'); ?&gt; </code></pre> <p>But it doesn't delete anything in the database. Any help please?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload