Re: Php form & row delete problems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Vincent Jordan" <vjordan@xxxxxxxxxxxxxx> wrote in message
news:200406251649.i5PGn0o09385@xxxxxxxxxxxxxxxxxxxxxxxxx
> 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

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux