Hey guys/gals,
I literally just started teaching myself MySQL today and have started to write a email list script for mass emails.
Ive got the adding emails and sending mail scripts working but i cannot figure out for the life of me what is wrong with the deleting script. I include the entire code and separated what is giving me the issue.
I changed the error message and believe what i have singled out is where the issue arises.
I know the connection info is correct because its the same i have used for the other two scripts and i get no issues so i assume its in the code somewhere.
<body>
<img src="blankface.jpg" width="161" height="350" alt="" style="float:right" />
<p>Please select the email addresses to delete from the email list and click Remove.</p>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<?php
$dbc = mysqli_connect('localhost', 'dmwimbley0606', 'password', 'example')
or die('Error connecting to MySQL server.');
// Delete the customer rows (only if the form has been submitted)
if (isset($_POST['submit'])) {
foreach ($_POST['todelete'] as $delete_id) {
$query = "SELECT FROM email_list WHERE id = $delete_id";
mysqli_query($dbc, $query)
or die('Error querying dHIHIHIHIHIHI.');
}
echo 'Customer(s) removed.<br />';
}
// Display the customer rows with checkboxes for deleting
$query = "SELECT * FROM email_list";
$result = mysqli_query($dbc, $query);
while ($row = mysqli_fetch_array($result)) {
echo '<input type="checkbox" value="' . $row['id'] . '" name="todelete[]" />';
echo $row['first_name'];
echo ' ' . $row['last_name'];
echo ' ' . $row['email'];
echo '<br />';
}
mysqli_close($dbc);
?>
<input type="submit" name="submit" value="Remove" />
</form>
</body>
Thanks,
David