0

I have table like the below one

I have to delete the unchecked value and new checked values into a database. How to achieve this? Already existed checkbox also will be posted again. But if they uncheck I need to delete. This is my below code:

$already_exist_category = array("68","70")
$newly_posted_category = array("124","125","68") or array("124","125");

How to update or delete and insert the newly posted id into the table?

1 Answer 1

1

First delete the id which is not there, then insert the data.

delete from table where id not in ($already_exist_category)

insert the new id here.
Sign up to request clarification or add additional context in comments.

2 Comments

its duplicating the category id
make sure you check before inserting the values to db you check if the row is already exista.

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.