I’m having a problem: the mail function doesn’t work. My best guess is that there’s something wrong in one of the three queries i’ve used, or that I haven’t fetched the data correctly. See commentary in the code for further explanation. Thanks in advance.
$q1 = mysqli_query($conn, " // selects list and loot columns from table participants
SELECT
list, loot
FROM
participants
");
$index = 0;
while($row = mysqli_fetch_assoc($q1)){ // loop to store the data in an associative array.
$loot[$index] = $row; // this is where $loot comes from
$index++;
}
for($i=1; $i<$result2[0]; $i++){ // $result2[0] is present in my code, i just didn't include it here as this worked fine
$q2 = mysqli_fetch_array(mysqli_query($conn, " // selects the email adresses of all participants, one by one
SELECT
emailadress
FROM
participants
WHERE
name = `'.$loot[$i]['loot'] . '`
"));
$q3 = mysqli_fetch_array(mysqli_query($conn, " // selects the names of the participants, one by one
SELECT
name
FROM
participants
WHERE
emailadress = `'. $q2[0] .'`
"));
mail(`'. $q2[0] .'`, "subject", "Hi `'. $q3[0] .'`, The list of your assigned person is: `'. $loot[$i]['list'] .'` greetings, the mailbot", NULL, "[email protected]"); // mails the participants their assigned lists and loot
}