/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function _get_emails_by_role( $role ) { $q = "SELECT u.mail AS email "; $q .= "FROM {users} u "; $q .= "INNER JOIN {users_roles} ur ON u.uid = ur.uid "; $q .= "INNER JOIN {role} r ON ur.rid = r.rid "; $q .= "WHERE r.name = '%s';"; $db = db_query($q, $role); $emails = ''; while ($row = db_fetch_object($db)) { $emails .= $row->email . ', '; } return $emails; }