Results 1 to 5 of 5

Thread: [RESOLVED] Print Array

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2008
    Posts
    790

    Resolved [RESOLVED] Print Array

    I am using Zend mail to send an email to people on their birthdays.

    On my php page, I query my mySQL database and form an array of information:

    Code:
    mysql_select_db($database_connect, $connect);
    $query_contacts = "SELECT Birthdate, contacts.First, contacts.Last, contacts.Email, contacts.Patient_Number AS Number, contacts.Patient_ID
    FROM contacts 
    WHERE contacts.Active = 'Y'
    AND contacts.Company_ID = '1'
    AND contacts.Birthday_Email = 'Y'
    AND contacts.Email LIKE '%@%'
    HAVING MONTH(Birthdate) = MONTH(CURDATE()) AND DAY(Birthdate) = DAY(CURDATE())
    ";
    $contacts = mysql_query($query_contacts, $connect) or die(mysql_error());
    $totalRows = mysql_num_rows($contacts);
    
    $emailBody = "";
    
    while($row_contacts = mysql_fetch_assoc($contacts))
    {
        $config = array('auth' => 'login', 'port' => 25, 'username'=> 'chris@chris.com', 'password'=>'password');	
    	$transport = new Zend_Mail_Transport_Smtp('chris@chris.com', $config);
    	
     
        $arr_ids[] = $row_contacts['Patient_ID'];
    
    ....
    
    code to send email via Zend mail goes here
    
    ....
    
    }
    The array, $arr_ids[], that stores Patient_IDs.... I'd like to send all the values in an email to me next so I can see who was emailed.

    Here's some of the code that I am using for the body of the email:

    Code:
    $body2 = "<font size='2' face='arial' color='black'>Hello, this is an automatic update.<br><br>We sent " . $totalRows  . "  emails to say 'Happy Birthday!' today.</font><br><br>";
    I want to have all the IDs listed in the email. How do I get that from the array and then insert it into the body of my php email?

    Thanks.

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Print Array

    You could use the implode function to turn the array into a string:
    PHP Code:
    implode("\r\n"$arr_ids
    Also, I assume you're sending the mail outside the while loop...

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2008
    Posts
    790

    Re: Print Array

    Thanks penagate. I was researching arrays and the implode function prior to posting this.

    I didn't know you could implode an array by "\r\n". That solved my problem nicely.

    Also, I assume you're sending the mail outside the while loop...
    I query my db to find all people whose birthdays are today. That's also where I keep all the names in an array. And then I send them an individual email to say Happy Birthday.

    I do all that within the while loop. I figured I'd have to in order for them to get a unique email.

    After that's done, I send a separate email (not in a loop) to me so that I can see who was emailed that day.

    It's been working very well for a few months, but I wanted to add a list of all the people who were emailed to the message that I receive daily.

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Print Array

    OK, that makes more sense. Glad to help.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2008
    Posts
    790

    Re: Print Array

    *phew*

    Glad to hear.

    Thanks penagate!!!!!

Posting Permissions

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



Click Here to Expand Forum to Full Width