While Loop
I am desperately trying to create an email form that has a number of checkboxes at the top of the page that allows the user to select multiple people (one email address per check box) or a department (multiple emails per checkbox).
I can get a single email address to echo from the database into the value fields for the people, but I am having issues getting all email addresses from specific column into a checkbox value.
I have been trying to learn to use the while loop but haven't managed to get it to work successfully yet.
To start with, I do not need to have checkboxes, but I do need a way that the user can select multiple people or groups of people to send the message to - if you have any other suggestions please let me know.
The method that I am using to loop the records is as follows;
<?php
$connection = mysql_connect("localhost", "username", "password") or die("Error connecting to database");
mysql_select_db("db_name", $connection);
$result = mysql_query("SELECT * FROM units", $connection) or die("error querying database");?>
Then this for the first checkbox;
<?php while($row_rs = mysql_fetch_assoc($result)){
echo $row_rs['chair_email'].',';}?>
Then this for the second;
<?php while($row_rs = mysql_fetch_assoc($result)){
echo $row_rs['sec_email'].',';}?>
But unfortunately the second set doesn't produce any results from the recordset.
Where am I going wrong?
I'm sure there must be an easier way....