I have a selection drop-down that is a single selection drop-down for a persons name and id. This is used to connect that person to an articles database. From the selection made in the form, I write the data into a relational database connecting the article to the user and I send the selected person an email.
What I need to do is change the drop-down to perform multi-select but also write multiple additions to the database and send out multiple emails as well. So for each name selected in the drop down, I need a new entry and a new email.
Example:
You choose from the following in a drop-down select field with the user id not displayed but posted in the background:
ID | Name
1 | Larry
2 | Tom
3 | Jane
4 | Chris
Currently if you choose Tom, the database grabs the article id (posted from the initial url {save.php?id=$row[0]} and writes into the connection database the article id and user id. From there it also sends an email to Tom to say, in part, "Article 5 has been saved into your account"
What I need to do is function where you if choose Tom, Jane and Chris, it performs a query to write a new record for all names to be connected with the same article and sends all of them their own email. To be clear, the email body can be the same, I just need the "to" portion of the name and email to obviously be the fluid portions of this.
There are some details kept out to save time, but that is the essential facts about what is done and what I need to do. I am certain I know how to do a multi-select, but I could be wrong. Where I need help is the multi-selected data being written in a database and sending out the multiple emails.
I should also note that not more than 5 or 6 names would be choosen. This is all behind a user accessed website only open to registered users.
If I've left anything out that needs clarification, etc, please let me know. I tried to only include relevant code and relevant facts.
Any and all help is greatly appreciated! Thank you!
Relevant Code for Form:
Relevant Code to Write to DB:
What I need to do is change the drop-down to perform multi-select but also write multiple additions to the database and send out multiple emails as well. So for each name selected in the drop down, I need a new entry and a new email.
Example:
You choose from the following in a drop-down select field with the user id not displayed but posted in the background:
ID | Name
1 | Larry
2 | Tom
3 | Jane
4 | Chris
Currently if you choose Tom, the database grabs the article id (posted from the initial url {save.php?id=$row[0]} and writes into the connection database the article id and user id. From there it also sends an email to Tom to say, in part, "Article 5 has been saved into your account"
What I need to do is function where you if choose Tom, Jane and Chris, it performs a query to write a new record for all names to be connected with the same article and sends all of them their own email. To be clear, the email body can be the same, I just need the "to" portion of the name and email to obviously be the fluid portions of this.
There are some details kept out to save time, but that is the essential facts about what is done and what I need to do. I am certain I know how to do a multi-select, but I could be wrong. Where I need help is the multi-selected data being written in a database and sending out the multiple emails.
I should also note that not more than 5 or 6 names would be choosen. This is all behind a user accessed website only open to registered users.
If I've left anything out that needs clarification, etc, please let me know. I tried to only include relevant code and relevant facts.
Any and all help is greatly appreciated! Thank you!
Relevant Code for Form:
Code:
print "<select size=\"3\" multiple=\"multiple\" name=\"users_id[]\">";
print "<option value='-' >Select from list</option>";
while ($row = mysql_fetch_assoc($result)){
$uid = $row['id'];
$fname = $row['fname'];
$lname = $row['lname'];
print "<option value=$users_id>$fname $lname</option>";
}
print "</select>";
Relevant Code to Write to DB:
Code:
$aid=$_POST['id'];
$uid=$_POST['uid'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
mysql_query("INSERT INTO table (aid, uid) VALUES ('$aid', '$uid')") ;
Last edited: