If you want to delete multiple items, you need to use array name condition
in checkbox.
Here's an example:

<form action = "delete.php" method = "post">
    <input type = "checkbox" name = "name_array[]" value = "value1">
    <input type = "checkbox" name = "name_array[]" value = "value2">
    
    <!-- more and more... -->
    
    <input type = "submit" name = "name" value = "GO">
</form>

Of course you can use a while loop to output the form.
Then in your PHP code that processes this form, you need to run a query for
every one of the data you want to delete:

if (count($_POST["name_array"]) > 0)
{
    foreach($_POST["name_array"] as $name_element)
    {
        // call a function to delete record
    }
else
{
    // print message because no checkbox has been selected
    exit;
}

Tony S. Wu 


Matt Nigh at [EMAIL PROTECTED] wrote:

> hi, i'm trying to delete multiple records at once from a mysql db and can't
> seem to figure out how to do so.
> here's the code i've been trying to troubleshoot with:
> 
> $result_insert = mysql_query("delete from $mysql_table where id = '8' AND
> where id = '18'");
> 
> 
> i've tried various things such as taking away the single quotes, replacing
> AND with a comma, etc.
> after i figure out how to delete multiple records, i need to figure out how
> to go about carrying data from checkboxes and finding a query to delete the
> records that were checked on the previous page:
> 
> ex.
> <input type=checkbox name=id value=1>
> <input type=checkbox name=id value=2>
> <input type=checkbox name=id value=3>
> etc.
> 
> 
> any help would be appreciated.
> 
> thanks very much,
> 
> 
> Matt
> 
> 




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

Reply via email to