Reputation: 19
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.
Upvotes: 0
Views: 210
Reputation: 63
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);
Upvotes: 1