1

here I have a table which its data come from database (Mysql DBMS) Table

In this table I can delete a book one by one but what I need is to delete multiple Book in once Something like this enter image description here

But Actually I have no Idea How to do That Can you guys do me a favor how to do that plz I will be thankful

4
  • 1
    What is your question exactly? Just give each row a checkbox and link them to the delete button. Commented Mar 3, 2016 at 18:04
  • My question is that part actually How to link that to a delete button Commented Mar 3, 2016 at 18:05
  • Use multiple checkboxes with same name. Then do a foreach Commented Mar 3, 2016 at 18:08
  • Ok Thanks Im trying to do I think I got it, I think Its somehow like multiple upload file Commented Mar 3, 2016 at 18:15

1 Answer 1

1

Create a list of checkboxes with the same name using [] notation, but different values, ids of records presumably:

<input type="checkbox" name="record_id[]" value="42" />
<input type="checkbox" name="record_id[]" value="43" />
<input type="checkbox" name="record_id[]" value="44" />
<input type="checkbox" name="record_id[]" value="45" />

After you select some of them, they will be passed to a server as $_POST['record_id'] array.

Do a foreach:

foreach ($_POST['record_id'] as $id) {
     // delete record with $id here
}

Or implode'em, for example:

$sql = "DELETE FROM `mytable` WHERE id IN (" . implode(', ', $_POST['record_id']) . ")";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.