I have the following code, which works to a certain degree:
if(isset($_POST['remove'])) {
$user = $_POST['user'];
$passcode = $_POST['passcode'];
$sql = "SELECT *
FROM admin
WHERE username = '" . $user . "'
and passcode ='".md5($passcode)."'";
$result = mysqli_query($conn,$sql);
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
$count = mysqli_num_rows($result);
if($count==0) {
echo "Invalid Credentials";
} else {
include 'config.php';
$cnt=array();
$listCheck = "'" .implode("','", $_POST['checkbox']) . "'";
$sql6 = "DELETE FROM `customer` WHERE `name` IN ($listCheck)";
$delete = mysqli_query ($conn,$sql6);
}
Issue is, it only deletes 1 of the selected rows. How do I modify the code so it deletes ALL of the selected rows?
<input type="submit" name="remove" class="btn2" value="Delete Selected">
<div>
<?php
$query1 = "SELECT `name` FROM `customer` ORDER BY `name` ASC ";
$result = mysqli_query($conn, $query1);
echo "<table>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td><input name='checkbox[]' type='checkbox' id='checkbox[]' value=" . $row['name'] . "></td>";
echo"</tr>";
}
echo "</table>";
echo "<br>";
?>
</div>
<form>containing the Checkboxes in questionmd5($passcode)? I sure hope for your sake that this isn't a live site; you will get hacked.ini_set('display_errors', 1); ini_set('log_errors',1); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);to the top of your script. This will force anymysqli_errors to generate an Exception that you can see on the browser and other errors will also be visible on your browser.