skazat <[EMAIL PROTECTED]> said something to this effect on 07/09/2001:
> use the CGI.pm module, checkbox values will come back as an array, so do
> something like, 
> 
> 
> my $q = new CGI; 
> my @checked_values = $q->param('whatever_row_i_want_to_chuck');
> 
> 
> then use the DBI module to chuck it from the SQL table,
> 
> use DBI; 
> my $dbh = DBI->connect("$data_source", $user, $pass);
> 
> foreach(@checked_values){
>         my $sth = $dbh -> prepare("DELETE FROM your_table WHERE id = ?");
>        $sth->execute($_);
>        $sth->finish;
> }

I'm not sure about Pg, but MySQL has the IN grouping function,
which would be much more efficient; replace the foreach loop with
something like:

  my $sql = 'DELETE FROM your_table WHERE id IN (' .
            join (', ', @checked_values) . ')';
  $dbh->do($sql);

If Pg doesn't support the IN clause (I think IN is standard ANSI
SQL, so it should), you can always do this:

  my $sql = 'DELETE FROM your_table WHERE id=' .
            join(' or id=', @checked_values);

Either way, you should definitely do it as one delete, not
$#checked_values deletes in a loop!

(darren)

-- 
Trying to be happy is like trying to build a machine for which the only
specification is that it should run noiselessly.

Reply via email to