Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8464213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:40:33+00:00 2026-06-10T14:40:33+00:00

How to delete multiple data from table with checkbox? I have this code: <form

  • 0

How to delete multiple data from table with checkbox?
I have this code:

<form id="prefForm" action="coments-del.php" method="post">

<?

$result = mysql_query("SELECT * FROM comments");      
$myrow = mysql_fetch_array($result);

do
{
    $res = mysql_query("SELECT title FROM data WHERE id=$myrow[post]");
    $row = mysql_fetch_array($res);
    printf ("
         <tr>
           <td>
                <input type='checkbox' name='id' value='%s'  />
                </td>        
                <td>%s</td>
           <td>%s</td>
                <td>%s</td>
         ",$myrow["id"],$myrow["id"],$myrow["author"],$myrow["text"]);
}
while ($myrow = mysql_fetch_array($result));
?>

<input name="submit-button" type="submit" value="Delete" />
</form>

Here is the coments-del.php where you get brought after submiting form in script above.

In the head is:

if (isset($_POST['id'])) { $id = $_POST['id']; }

At the body is the code that proccess the deleting.

<?php 
if (isset($id)) {
    $result = mysql_query ("DELETE FROM comments WHERE id='$id'");

    if ($result == 'true') {echo "Comment Deleted!";}
    else {echo "Error: Nothing was deleted!";}

} else {
    echo "Unknown Error! Contact Administrator.";
}

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:40:34+00:00Added an answer on June 10, 2026 at 2:40 pm

    First step is to make your checkbox name an array.

    <input type='checkbox' name='id[]' value='%s'  />
    

    And when your script receive the post, parse that array out to the appropriate sql clause.

    $clause="";
    if (isset($_POST['id'])) { 
       foreach ($_POST['id'] as $p)
       $clause.="id='$p' OR"; 
    }
    $clause=substr($clause,0,-2);
    

    Finally put the clause into the query in the where clause.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$(.delete).click( function() { var thesender = this; $(thesender).text(Del...); $.getJSON(ajax.php, {}, function(data) { if (data[result])
I have created a stored procedure to delete data from multiple tables. my work
I'm creating multiple form retrieving data from jquery. after that i want to work
I know of two ways to delete data from a database table DELETE it
I use a form where i have listed the data from database like title,
I have table rows of data in html being filled from a CGI application.
I have data imported from an excel sheet into a table in db. Now
I have multiple jquery delegate functions to delete items from lists. They work fine
I want to delete multiple records at once. I have two tables, one that
I trying to figure out how I can delete from multiple tables in SQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.