Results 1 to 1 of 1

Thread: Mysql and Arrays logic hook Problem

  1. #1
    vantagejuan is offline Sugar Community Member
    Join Date
    Dec 2007
    Posts
    70

    Default Mysql and Arrays logic hook Problem

    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;
    }
    Last edited by vantagejuan; 2009-10-27 at 03:05 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Logic hook problem....
    By amith sai in forum Developer Help
    Replies: 1
    Last Post: 2009-10-01, 08:05 AM
  2. Problem counting in logic hook
    By dekleinemedia in forum Help
    Replies: 10
    Last Post: 2009-07-22, 08:21 AM
  3. Logic Hook - before save problem
    By kinshibuya in forum Help
    Replies: 7
    Last Post: 2009-07-21, 07:00 PM
  4. Logic-hook problem - Teams
    By Spinaker in forum Help
    Replies: 17
    Last Post: 2009-03-30, 11:14 AM
  5. I have problem regarding logic hook
    By cryptex in forum Developer Help
    Replies: 6
    Last Post: 2008-12-02, 06:41 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •