There must be an easier way
Posted: Fri Jul 28, 2006 6:14 am
Hi
I am writing a script to send mail to certain groups of staff. I have check boxes for chosing which group it should be sent to. I am writing a script so that when the checkboxes are selected it will only go to that group of staff. If the staff member is in more than one group he should only receive it once.
All the deatils are stored in a mysql database looking something like this
id
email_address
DDPG (Y/N)
TDPG (Y/N)
SG (Y/N)
At the moment I am using this code
THe problem is I need to create a new list and there are going to be a lot more options. There must be an easier way. Please help
I am writing a script to send mail to certain groups of staff. I have check boxes for chosing which group it should be sent to. I am writing a script so that when the checkboxes are selected it will only go to that group of staff. If the staff member is in more than one group he should only receive it once.
All the deatils are stored in a mysql database looking something like this
id
email_address
DDPG (Y/N)
TDPG (Y/N)
SG (Y/N)
At the moment I am using this code
Code: Select all
if($row_email['SG'] == 'Y' && $row_email['DDPG'] == 'Y' && $row_email['TDPG'] == 'Y' ) {
$query1 = "SG = 'Y' OR DDPG = 'Y' OR TDPG = 'Y'";
}
//YNN
if($row_email['SG'] == 'Y' && $row_email['DDPG'] == 'N' && $row_email['TDPG'] == 'N' ) {
$query1 = "SG = 'Y'";
}
//NYN
if($row_email['SG'] == 'N' && $row_email['DDPG'] == 'Y' && $row_email['TDPG'] == 'N' ) {
$query1 = "DDPG = 'Y'";
}
//NNY
if($row_email['SG'] == 'N' && $row_email['DDPG'] == 'N' && $row_email['TDPG'] == 'Y' ) {
$query1 = "TDPG = 'Y'";
}
//YYN
if($row_email['SG'] == 'Y' && $row_email['DDPG'] == 'Y' && $row_email['TDPG'] == 'N' ) {
$query1 = "SG = 'Y' OR DDPG = 'Y'";
}
//NYY
if($row_email['SG'] == 'N' && $row_email['DDPG'] == 'Y' && $row_email['TDPG'] == 'Y' ) {
$query1 = "DDPG = 'Y' OR TDPG = 'Y'";
}
//YNY
if($row_email['SG'] == 'Y' && $row_email['DDPG'] == 'N' && $row_email['TDPG'] == 'Y' ) {
$query1 = "SG = 'Y' OR TDPG = 'Y'";
}
mysql_select_db($database_db_connect, $db_connect);
$query_list = "SELECT * FROM mailing_list WHERE ".$query1;
$list = mysql_query($query_list, $db_connect) or die(mysql_error());
$row_list = mysql_fetch_assoc($list);
$totalRows_list = mysql_num_rows($list);