mysql - Delete multiple checkbox values in php
Get the solution ↓↓↓I am new to php. I have inserted some multiple checkboxes' values into my database table using implode. Here is the code.
`$checkBox = implode(",", $_POST['car']);
if(isset($_POST['addcar']))
{
$username = $_SESSION['username'];
$query1="INSERT INTO vehicle (username,car) VALUES ('$username', '" . $checkBox . "') ";
mysqli_query($db,$query1);
}`
But i can't find how to delete records. Could someone please help me. Thank you for the answers in advance.
Answer
Solution:
First of all, you've to be aware of SQL-injection. Since you are new at PHP, hope that you'll learn that terms. Now I am just going trough your code.Try this
:
$checkBox = implode(",", $_POST['car']);
$query1="DELETE FROM table WHERE car IN ($checkBox) ";
mysqli_query($db,$query1);
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: xml parsing error: no root element found
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.