<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://php.apsique.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>Php y otras yerbas - Como borrar múltiples registros con checkbox - Comentarios</title>
 <link>http://php.apsique.com/contenido/borrar_multiples_registros_con_checkbox</link>
 <description>Comentarios para &quot;Como borrar múltiples registros con checkbox&quot;</description>
 <language>es</language>
<item>
 <title>Revisa que:
1.- El checkbox</title>
 <link>http://php.apsique.com/contenido/borrar_multiples_registros_con_checkbox#comment-115699</link>
 <description>&lt;p&gt;Revisa que:&lt;br /&gt;
1.- El checkbox tenga como al final un &quot;[]&quot; si en el &#039;value&#039; está el id. Bastaría con hacer un print_r en el $_POST[&#039;NOMBRE_DE_MI_VARIABLE&#039;] para verificar que estás enviando bien la información desde el cliente&lt;br /&gt;
2.- La tabla donde se almacena la información y la query están bien construidas. Manda un ejemplo, si quieres una opinión mejor&lt;/p&gt;
&lt;p&gt;P.D.: No pongas que estás apurado. Ese es problema tuyo, la verdad.&lt;/p&gt;
</description>
 <pubDate>Tue, 16 Mar 2010 08:02:03 -0700</pubDate>
 <dc:creator>clbustos</dc:creator>
 <guid isPermaLink="false">comment 115699 at http://php.apsique.com</guid>
</item>
<item>
 <title>buenas tards tengo una</title>
 <link>http://php.apsique.com/contenido/borrar_multiples_registros_con_checkbox#comment-115696</link>
 <description>&lt;p&gt;buenas tards tengo una duda... &lt;/p&gt;
&lt;p&gt;yo tengo una lista de personas a las que cada una tiene una casilla checkbox para que el usuario selecione varias persona para asignarle un evento..!! pero necesito guardar esa selecion en una tabla de la base de datos ..&lt;/p&gt;
&lt;p&gt;lo intente hacer pero solo me almacena una sola persona.. como podria hacer es urgente..&lt;/p&gt;
</description>
 <pubDate>Tue, 16 Mar 2010 07:10:08 -0700</pubDate>
 <dc:creator>ANGELF</dc:creator>
 <guid isPermaLink="false">comment 115696 at http://php.apsique.com</guid>
</item>
<item>
 <title>hola a todos excelente</title>
 <link>http://php.apsique.com/contenido/borrar_multiples_registros_con_checkbox#comment-115034</link>
 <description>&lt;p&gt;hola a todos excelente solucion la hepuesto en practica en un proyecto y funciona excelente... solo que ahora tengo un problema el ejemplo lo modifique para que se actualicen los datos de una tabla pero ... los dos campos con los que actualizo la tabla requieren ser validados ya que los usuarios finales tienen problemas para recordar que deben llenarlos cuando quieren modificar los datos... no se si me hecho entender pero quiero que al seleccionar el checkbox de un dato valide que los dos campos que tengo en la misma linea un texto y una lista despleglable de diligencien o seleccionen segun corresponda&lt;/p&gt;
&lt;p&gt;mucahs gracias&lt;/p&gt;
</description>
 <pubDate>Sat, 27 Feb 2010 13:58:21 -0800</pubDate>
 <dc:creator>emerson</dc:creator>
 <guid isPermaLink="false">comment 115034 at http://php.apsique.com</guid>
</item>
<item>
 <title>buenas tenga una tabla que</title>
 <link>http://php.apsique.com/contenido/borrar_multiples_registros_con_checkbox#comment-114526</link>
 <description>&lt;p&gt;buenas tenga una tabla que es llenada por registros de una base de datos y es mostrada al usuario, lo que yo necesito es que al lado de cada registro aparezcan botones de borrar o modificar y no encuentro la forma de hacerlo&lt;/p&gt;
&lt;p&gt;gracias de antemano&lt;/p&gt;
</description>
 <pubDate>Fri, 05 Feb 2010 10:58:05 -0800</pubDate>
 <dc:creator>wolcutor</dc:creator>
 <guid isPermaLink="false">comment 114526 at http://php.apsique.com</guid>
</item>
<item>
 <title>Hola, ¿cómo es, en un</title>
 <link>http://php.apsique.com/contenido/borrar_multiples_registros_con_checkbox#comment-113984</link>
 <description>&lt;p&gt;Hola, ¿cómo es, en un ejemplo de sintaxis PHP, en un archivo UPDATE (para modificar) y en un INSERT (alta) agregar un par de checkbox y un par de radiales a un formulario que tiene tambien otros datos ( en celdas comunes, mínimos: nombre, teléfono, etc)?&lt;br /&gt;
Me doy cuenta que tengo que trabajar variables y lo de IN en el select, pero al actualizar el UPDATE se me borran los registros.&lt;br /&gt;
Me gustaría ver un ejemplo genérico de esos dos archivos. Muchas gracias.&lt;/p&gt;
</description>
 <pubDate>Tue, 19 Jan 2010 07:16:38 -0800</pubDate>
 <dc:creator>Perejilillo desconocido</dc:creator>
 <guid isPermaLink="false">comment 113984 at http://php.apsique.com</guid>
</item>
<item>
 <title>me gustaria que me pasaras</title>
 <link>http://php.apsique.com/contenido/borrar_multiples_registros_con_checkbox#comment-106054</link>
 <description>&lt;p&gt;me gustaria que me pasaras tu correo tngo preguntas sobre un sistema que estoi haciendo mi correo es gustavo_bam87@hotmail.com&lt;/p&gt;
</description>
 <pubDate>Wed, 16 Dec 2009 12:34:39 -0800</pubDate>
 <dc:creator>root</dc:creator>
 <guid isPermaLink="false">comment 106054 at http://php.apsique.com</guid>
</item>
<item>
 <title>hola si  tengo esto
como</title>
 <link>http://php.apsique.com/contenido/borrar_multiples_registros_con_checkbox#comment-101615</link>
 <description>&lt;p&gt;hola si  tengo esto&lt;br /&gt;
como hago para leerlo con php alquien me ayude por favor xD desde ya gracias ...&lt;/p&gt;
</description>
 <pubDate>Thu, 26 Nov 2009 09:26:15 -0800</pubDate>
 <dc:creator>sdarknot</dc:creator>
 <guid isPermaLink="false">comment 101615 at http://php.apsique.com</guid>
</item>
<item>
 <title>Gracias, me sirvio de mucho,</title>
 <link>http://php.apsique.com/contenido/borrar_multiples_registros_con_checkbox#comment-101371</link>
 <description>&lt;p&gt;Gracias, me sirvio de mucho, no sabia como eliminar varios registros pero ahora si jeje, pensaba hacerlo de la manera incorrecta pero mejor me puse a buscar y llege a este sitio. Gracias nuevamente.&lt;/p&gt;
</description>
 <pubDate>Mon, 16 Nov 2009 13:52:37 -0800</pubDate>
 <dc:creator>ROM4</dc:creator>
 <guid isPermaLink="false">comment 101371 at http://php.apsique.com</guid>
</item>
<item>
 <title>como borrar varios registros</title>
 <link>http://php.apsique.com/contenido/borrar_multiples_registros_con_checkbox#comment-99479</link>
 <description>&lt;p&gt;como borrar varios registros en un checkbox  y ordenarlos&lt;/p&gt;
</description>
 <pubDate>Sun, 20 Sep 2009 10:32:52 -0700</pubDate>
 <dc:creator>rosa</dc:creator>
 <guid isPermaLink="false">comment 99479 at http://php.apsique.com</guid>
</item>
<item>
 <title>hola necesito que me ayudes</title>
 <link>http://php.apsique.com/contenido/borrar_multiples_registros_con_checkbox#comment-99200</link>
 <description>&lt;p&gt;hola necesito que me ayudes tengo un reporte y quiero eliminarlos como tipo bandeja correo de hotmail por favor ayudame&lt;/p&gt;
</description>
 <pubDate>Fri, 11 Sep 2009 05:42:27 -0700</pubDate>
 <dc:creator>yorman</dc:creator>
 <guid isPermaLink="false">comment 99200 at http://php.apsique.com</guid>
</item>
<item>
 <title>Hola Buhilardo ayudam x</title>
 <link>http://php.apsique.com/contenido/borrar_multiples_registros_con_checkbox#comment-98433</link>
 <description>&lt;p&gt;Hola Buhilardo ayudam x fa&lt;br /&gt;
stoy haciendo una aplicacion en la cual debo ir a la pagina de guardar notas pero debo llevar el codigo del estudiante seleccionado no se como hacerlo&lt;br /&gt;
si tienes algo con q ayudarme gracias Saludos...&lt;/p&gt;
</description>
 <pubDate>Wed, 12 Aug 2009 12:47:09 -0700</pubDate>
 <dc:creator>pana</dc:creator>
 <guid isPermaLink="false">comment 98433 at http://php.apsique.com</guid>
</item>
<item>
 <title>soy estudiante del tecnologo</title>
 <link>http://php.apsique.com/contenido/borrar_multiples_registros_con_checkbox#comment-98428</link>
 <description>&lt;p&gt;soy estudiante del tecnologo en analisis y desarrollo de sistemas necesito regresar automaticamente a la pagina donde elimine para que se observe que el registro fue eliminado&lt;br /&gt;
tengo la siguiente linea de codigo para eliminar y me funciona&lt;br /&gt;
	  mysql_query(&quot;delete from pais where id =&#039;$id&#039;&quot;)&lt;br /&gt;
y tengo la siguiente linea de codigo para regresar pero no automaticamente&lt;br /&gt;
sino con un link&lt;br /&gt;
              &lt;a href=&quot;pais.php&quot;&gt;volver&lt;/a&gt;&lt;br /&gt;
lo necesito para mañana porque el profe me va a poner a sustentar gracias por la ayuda hoy por mi mañana por alguien&lt;/p&gt;
</description>
 <pubDate>Wed, 12 Aug 2009 10:24:06 -0700</pubDate>
 <dc:creator>oscar alexander</dc:creator>
 <guid isPermaLink="false">comment 98428 at http://php.apsique.com</guid>
</item>
<item>
 <title>Gracias, estaba buscando un</title>
 <link>http://php.apsique.com/contenido/borrar_multiples_registros_con_checkbox#comment-97805</link>
 <description>&lt;p&gt;Gracias, estaba buscando un codigo que funcionara y el ultimo funciono perfectamente&lt;/p&gt;
</description>
 <pubDate>Sun, 19 Jul 2009 19:38:59 -0700</pubDate>
 <dc:creator>Edwin</dc:creator>
 <guid isPermaLink="false">comment 97805 at http://php.apsique.com</guid>
</item>
<item>
 <title>hola la verdad es muy buena</title>
 <link>http://php.apsique.com/contenido/borrar_multiples_registros_con_checkbox#comment-97303</link>
 <description>&lt;p&gt;hola la verdad es muy buena explicacion pero en mi bsase de datos tengo caracteres y ala hora de ejecutar la consulta para que me borre los campos seleccionados me ace falta poner unas &#039; &#039; entre cada campo que debuelve el arreglo como ago eso ya intente con la funcion $aLista[]=&quot;&#039;&quot;.str_replace(&quot;&#039;&quot;,&quot;\\&#039;&quot;,$lista).&quot;&#039;&quot;;&lt;br /&gt;
y no se que pasa no fucniona te agradesco y me puedas ayudar&lt;br /&gt;
saludos&lt;/p&gt;
</description>
 <pubDate>Mon, 29 Jun 2009 11:20:28 -0700</pubDate>
 <dc:creator>rayas666</dc:creator>
 <guid isPermaLink="false">comment 97303 at http://php.apsique.com</guid>
</item>
<item>
 <title>hola a todos quisiera</title>
 <link>http://php.apsique.com/contenido/borrar_multiples_registros_con_checkbox#comment-97219</link>
 <description>&lt;p&gt;hola a todos quisiera consultar lo siguiente:&lt;br /&gt;
para empezar tengo una lista de clientes en la que cada fila tiene un checkbox lo que pretendo es que al hacer click sobre el botom actualizar me lleve a otra pagina php donde se muestren los campos de la fila en la marque el checkbox&lt;/p&gt;
</description>
 <pubDate>Thu, 25 Jun 2009 16:19:10 -0700</pubDate>
 <dc:creator>spaimilt</dc:creator>
 <guid isPermaLink="false">comment 97219 at http://php.apsique.com</guid>
</item>
<item>
 <title>Como borrar múltiples registros con checkbox</title>
 <link>http://php.apsique.com/contenido/borrar_multiples_registros_con_checkbox</link>
 <description>&lt;p&gt;Este último tiempo, un simpático chico argentino se ha vuelto cliente habitual de mi MSN. Me acaba de codeguntar como eliminar múltiples campos de una base de datos vía checkbox. Es una interesante consulta, así que les daré una breve explicación de las diversas formas de hacerlo.&lt;/p&gt;
&lt;!--break--&gt;
&lt;p&gt;
Primero, se deben codeparar los campos de manera adecuada. Para ello, hay dos formas.&lt;/p&gt;
&lt;p&gt;La que ocupo yo, por sanidad mental, es la siguiente&lt;/p&gt;
&lt;div class=&#039;code&#039;&gt;&lt;div class=&quot;hl-main&quot;&gt;&lt;ol class=&quot;hl-main&quot;&gt;&lt;li&gt;&amp;nbsp;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&#039;&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;checkbox&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&#039; &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&#039;&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;campos&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;[$&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;]&#039;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Donde $id es el valor del id para la tupla que queremos borrar. Si enviamos por post, la función php que recibe debe ser similar a la siguiente&lt;/p&gt;
&lt;div class=&#039;code&#039;&gt;&lt;div class=&quot;hl-main&quot;&gt;&lt;ol class=&quot;hl-main&quot;&gt;&lt;li&gt;&amp;nbsp;&lt;span class=&quot;hl-inlinetags&quot;&gt;&amp;lt;?php&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;empty&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;campos&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;    &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$aLista&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;array_keys&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;campos&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;    &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$sQuery&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;DELETE FROM tabla where id IN (&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;implode&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$aLista&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-inlinetags&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Esa es la forma más simple. Una de las cosas que me molestan mucho de las aplicaciones que he visto es que casi nadie se molesta en usar el IN. Esta instrucción les permite seleccionar 1 o más valores para un campo, con un mínimo de utilización de recursos. La forma ineficiente sería&lt;/p&gt;
&lt;div class=&#039;code&#039;&gt;&lt;div class=&quot;hl-main&quot;&gt;&lt;ol class=&quot;hl-main&quot;&gt;&lt;li&gt;&amp;nbsp;&lt;span class=&quot;hl-inlinetags&quot;&gt;&amp;lt;?php&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;empty&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;campos&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;    &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$aLista&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;array_keys&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;campos&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;    &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;foreach&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$aLista&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$iId&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;    &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$sQuery&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;DELETE FROM tabla where id=&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$iId&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-inlinetags&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;¿Por qué es mala esta última forma? Porque para cada campo borrado, se debe realizar una nueva conexión a la base de datos. Usando IN, el sistema de base de datos busca de forma muy rápida en la tabla que valores debe borrar y podemos obtener un aumento de rendimiento de 100% o más!
&lt;/p&gt;
&lt;p&gt;Ahora, la segunda forma:&lt;/p&gt;
&lt;p&gt;Para esto, debemos usar en los valores de los checkbox&lt;/p&gt;
&lt;div class=&#039;code&#039;&gt;&lt;div class=&quot;hl-main&quot;&gt;&lt;ol class=&quot;hl-main&quot;&gt;&lt;li&gt;&amp;nbsp;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&#039;&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;checkbox&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&#039; &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&#039;&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;campos&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;[]&#039; &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&#039;$&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Donde $id es el valor del id para la tupla que queremos borrar. La función php queda así&lt;/p&gt;
&lt;div class=&#039;code&#039;&gt;&lt;div class=&quot;hl-main&quot;&gt;&lt;ol class=&quot;hl-main&quot;&gt;&lt;li&gt;&amp;nbsp;&lt;span class=&quot;hl-inlinetags&quot;&gt;&amp;lt;?php&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;empty&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;campos&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;    &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$aLista&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;campos&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;    &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$sQuery&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;DELETE FROM tabla where id IN (&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;implode&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;$aLista&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-inlinetags&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Ustedes dirán que esta forma es más sencilla. Claro, pero no es genérica. La primera forma nos permite incorporar varios valores de variable en el mismo input. Por ejemplo, valores de codeferencia distintos para varios usuarios
&lt;div class=&#039;code&#039;&gt;&lt;div class=&quot;hl-main&quot;&gt;&lt;ol class=&quot;hl-main&quot;&gt;&lt;li&gt;&amp;nbsp;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&#039;&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;checkbox&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&#039; &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&#039;&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;campos&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;[$&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;id_usuario&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;][$&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;id_codeferencia&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;]&#039;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;
Cosa que de la segunda forma quedaría
&lt;div class=&#039;code&#039;&gt;&lt;div class=&quot;hl-main&quot;&gt;&lt;ol class=&quot;hl-main&quot;&gt;&lt;li&gt;&amp;nbsp;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&#039;&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;checkbox&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&#039; &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&#039;&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;campos&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;[$&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;id_usuario&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;][]&#039; &lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&#039;$&lt;/span&gt;&lt;span class=&quot;hl-var&quot;&gt;id_codeferencia&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Lo cual, a mi entender, no es tan bonito.&lt;/p&gt;

&lt;p&gt;Nos vemos!&lt;/p&gt;</description>
 <comments>http://php.apsique.com/contenido/borrar_multiples_registros_con_checkbox#comments</comments>
 <category domain="http://php.apsique.com/lenguajes/php/dummies">Php para dummies</category>
 <category domain="http://php.apsique.com/lenguajes/sql">SQL</category>
 <pubDate>Sun, 13 Feb 2005 18:09:29 -0800</pubDate>
 <dc:creator>clbustos</dc:creator>
 <guid isPermaLink="false">383 at http://php.apsique.com</guid>
</item>
</channel>
</rss>
