Re: Php form & row delete problems

From: Date: Fri, 25 Jun 2004 17:35:23 +0000
Subject: Re: Php form & row delete problems
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-34965@lists.php.net to get a copy of this message
"Vincent Jordan" <vjordan@smartparts.com> wrote in message news:200406251649.i5PGn0o09385@lsh119.siteprotect.com... > I have a table that display's a list of users in a mysql db. In the table I > have a echo "<input type="checkbox" name"{$row[$user_id]}"> > {$row[$username]}, {$row[$password}, {$row[$isactive]}; > > ( this is not the exact code but its pretty close. ) > > What I would like to accomplish is after query and print rows. Each row has > a check box and if the box is checked and delete button is clicked it is > passed to userdel.php which would take the user_id and delete row. > > Any help would be greatly appreciated. Write your checkbox the following way: echo "<input type=\"checkbox\" name\"users[{$row[$user_id]}]\">"; After submitting $_POST['users'] will be an array containing all selected user ids. You can then just loop through and do your delete queries: foreach ($_POST['users'] as $user_id => $value) { $query = 'DELETE FROM table where user_id = ' . $user_id; // commit query } Hope this helps, Torsten Roehr

« previous php.db (#34965) next »