I have a form with a number of fields to fill out. Below these fields is a list that's generated by the DB for the available users to contact - each with a checkbox next to their name. I have it working so it sends all the emails out to each selected user and then creates the report in the DB. My question... how do I ALSO insert each username from the array into the DB and have it tied to the report that is created in the INSERT statement below? The report creates id_report and that is my key across all tables to tie everything together. I didn't want the usernames inserted into the DB without some way of linking it to the report that's inserted in this code.
Thanks!
$number = count($usernames);
for ($i=0; $i<=$number; $i++)
{
$user = $usernames[$i];
if ($user[$i] <> '') {
mail ($user, "Please submit information for REPORT: " . $title . ". Due NLT: " . $nlt_date, $outgoing_email_message);
}
}
$query = "INSERT INTO reports (main_office, office, title, title_of_doc, cdrl, doc_num, version, acc_rej, doc_date, date_distributed, deadline_date, deadline_time, author, date_resp_rcvd, rcm_date, misc_comments, username, file, outgoing_email_message)
VALUES
('$main_office', '$office', '$title', '$title_of_doc', '$cdrl', '$doc_num', '$version', '$acc_rej', '$doc_date', '$date_distributed', '$deadline_date', '$deadline_time', '$author', '$date_resp_rcvd', '$rcm_date', '$misc_comments', '$username[$i]', '$file', '$outgoing_email_message')";
mysql_query($query) or die(mysql_error()); ?>