I have a logic hook, where i want to send a notification to each member of the contacts associated security group. I'm currently not able to retrieve the user_name(s) associated with the assigned security groups. each user's user_name is also their email address to be added to the notification. I'm having trouble with querying the database (mysql) and handling the results since I have to input them back into another query as an array. I'm not very good with arrays.
all users have their user names as their email addresses, which is why the last query is for the user name out of the users table. $to [$value] = $value; is the variable that assigns the email address to the email function that isn't in the script here. maybe there's an easier way to do this, but if not, I would greatly appreciate any help in fixing my handling of the queries and arrays as well as any syntax issues.
The code is as follows:
Code:$sql3 = "SELECT securitygroup_id FROM securitygroups_records WHERE record_id = '$bean->id'"; $res3 = mysql_query($sql3, $connection_code_field); while ($row = mysql_fetch_array($res3)){ $securitygroup_id[] = $row['securitygroup_id']; } $sql4 = "SELECT user_id FROM securitygroups_users WHERE securitygroup_id = '{$securitygroup_id}'"; $res4 = mysql_query($sql4, $connection_code_field); while ($row = mysql_fetch_array($res4)) { $user_id[] = $row['user_id']; } $sql5 = "SELECT user_name FROM users WHERE id = '{$user_id}'"; $res5 = mysql_query($sql5, $connection_code_field); while ($row = mysql_fetch_array($res5)) { $user_name[] = $row['user_name']; } foreach ($user_name as $value){ $to [$value] = $value; }


LinkBack URL
About LinkBacks



Reply With Quote
Bookmarks