lundi 3 octobre 2016

PHP Assigning database values to a checkbox

Using PHPMailer, I am planning to submit an email to sets of distribution lists depending on which checkbox is checked within a form. So this means that each checkbox contain multiple email addresses. On mySQL database, I have set a column named "region" with row values Global, NAM and EMEA and set another column which has their corresponding email addresses and the last column for checkboxID. :

$sql = "SELECT * FROM distrolist";
$result = mysqli_query($connection, $sql);
if (isset($result) && is_resource($result)) { }
?>

<?php while ($row = $result->fetch_assoc()) : ?>

<input name="checkbox[]" type="checkbox" id="<?php echo $row['checkboxID']; ?>" value="<?php echo $row['region']; ?>" /><label for="<?php echo $row['region']; ?>"><?php echo $row['region']; ?></label>

<?php endwhile ; ?>

My problem is figuring out how to assign the email addresses of the checked checkbox to the

$mail->AddAddress($email); 

in PHPMailer. Please help.

Aucun commentaire:

Enregistrer un commentaire