Re: [phplib] OT: Deleting Queries from Checkbox From: Ben Curtis (benc <email protected>)
Date: 05/16/01

I usually do this as follows:

displaylist.html (using phplib's templates):
...
<!-- BEGIN row -->
<input type="checkbox" name="deletelist[]" value="{itemid}">{itemname}
<!-- END row-->

So, that list is populated by your "select ... where ..." query.

Then, process the list to delete like so:

dostuff.php:
if ($deletelist[1]) $deletestr = join(',',$deletelist);
elseif ($deletelist[0]) $deletestr = $deletelist[0];

if ($deletestr)
  mysql_query("delete from test_table where itemid in ($deletestr)");

On Wed, May 16, 2001 at 11:47:08AM -0400, HurricaneIndy <email protected> wrote:
> Hey all,
> I have query that lists all the rows in a table. I would like to be able to delete any of them using a checkbox. I added the checkbox tags in a while loop along with the rest of the queries so it prints out nicely. Of course I have a statement like:
>
> mysql_query("DELETE FROM test_table WHERE ????")
>
> This is the part I am stuck at...How exactly do I write this part of the code not knowing how many checkboxes will be selected to delete?
>
> Thanks in advance guys..
>
> Indy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: phplib-unsubscribe <email protected>
> For additional commands, e-mail: phplib-help <email protected>

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>