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

  • Home
  • SEARCH
  • 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 4076754
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:27:55+00:00 2026-05-20T17:27:55+00:00

I am trying to delete multiple records using check boxes. I’ve loaded each check

  • 0

I am trying to delete multiple records using check boxes. I’ve loaded each check box with the record ID:

<?php $row_count = 1; do {  ?>
    <tr <?php if ($row_count%2) { ?>bgcolor="#F4F4F4"<?php } ?>>
      <td align="center" ><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row_contactlist['contact_id']; ?>"></td>
      <td align="center" ><p><?php echo $row_contactlist['contact_id'];?></p></td>
    </tr>
    <?php $row_count++; } while ($row_contactlist = mysql_fetch_assoc($contactlist)); ?>

I’m running the delete using the following link:

<a class="addcontact" href="delete.php?mContact=<?php for($i=0;$i<=$row_count;$i++) { $del_id = $checkbox[$i]; } echo $del_id ?>" style="border-bottom:0px" >Delete Contact(s)</a>  

that runs delete.php

if (isset($_GET['mContact'])) {
mysql_query("DELETE FROM contacts WHERE contact_id = ".$_GET['mContact']."");
mysql_query("DELETE FROM history WHERE history_contact = ".$_GET['mContact']."");
mysql_query("DELETE FROM notes WHERE note_contact = ".$_GET['mContact']."");
redirect('You have deleted some contacts',"contacts.php");
}

The redirect works i.e. the contacts page reloads with ‘you have deleted some contacts’ and it looks like I get no errors, but none of the contacts are deleted.

UPDATE:
Thanks guys very speedy response. Total newb to PHP so everything is massively appreciated.

So I’ll use a sumbit button not a hyperlink:

<td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td>
  • 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-05-20T17:27:55+00:00Added an answer on May 20, 2026 at 5:27 pm

    I believe you’re having a mixup dealing with the selection of the criteria to be deleted.

    The link that takes the user to the delete page has nothing to do with the checkboxes in the code.

    I believe what you want to do is

    1. Create the checkboxes (and if you want something to be deleted by default, set checked="checked"
    2. Change the <a href..> to a submit button
    3. In the delete.php the checkboxes will be in an array $_GET['checkboxes'], which you can iterate through

    NOW, onto the issues that @JohnP alluded to:

    1. This is pretty insecure way to do this unless you have removed all your validation code before posting here.
    2. I would recommend passing everything by $_POST for a little bit more security through obscurity
    3. Check that the user has the privileges to delete the rows that they are attempting to delete.
    4. Set a LIMIT 1 on each delete (or update) query so you don’t accidentally delete all the rows in your database.

    UPDATE

    If you want to have a single delete link, you would need to add the link inside the do...while loop. It appears that you have the link outside that loop and you loop through every result and add them all to the mContact token. As a single, long string of numbers, your handling script does not have a way of parsing that information without delimiters.

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

Sidebar

Related Questions

I am trying to figure out how I can delete multiple records using check
I am trying to delete multiple record(s) by using codeigniter $this->db->delete() and $this->db->where() I
im trying to do delete records from multiple database tables. For error handling i'm
I'm trying to allow users to delete multiple records, they click a link delete
Using Doctrine , I am trying to delete records in a single table based
I trying to figure out how I can delete from multiple tables in SQL
I am trying to delete MySQL table rows from a Web page using Perl.
I'm trying to delete all rows in a table using Castle ActiveRecord. Normally, I
I am trying to delete a files. I check the date and delete if
If I'm trying to delete multiple rows from a table and one of those

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.