appending array of data to the message parameter of send_email() |
[eluser]Brad K Morse[/eluser]
I have a controller function email Code: function email() { I have a form that you can select the venue chair you want to send an email to, once you hit send, it sends an email via send_email() SS http://cl.ly/3f1M1z181h2O3x1d322E It works successfully, once the message is sent, it sends it, then displays the email-sent-view. I want to include more within the message that gets sent. I need it to include a list of names from the data table, where venue_id equals $_POST['venue_id'], which is value of the drop-down box you see in the screenshot (http://cl.ly/3f1M1z181h2O3x1d322E) I have the function sendChairVolunteerList() that gets the venue_id that was posted, runs a get('data') active record call, stores into $data array, seen below Code: function sendChairVolunteerList() { I am new to CI, so inserting the data array (list of volunteers "select from data where $_POST['venue_id'] = venue_id") into the message parameter of send_email() is new to me. Any help is appreciated.
[eluser]zac[/eluser]
You need to build your message separately, then pass it in to send_email(). Something like this: Code: if($_POST) { Or if building your message directly in the function is too awkward, use a view as a template. Setting the third argument to 'true' returns the parsed view instead of rendering it: Code: $msg = $this->load->view('email-message',$data,true);
[eluser]Brad K Morse[/eluser]
It is not printing the list of volunteers into $msg It gives error: Message: Object of class stdClass could not be converted to string which is this line Code: $msg .= implode(", ", $data['volunteers']); // convert array to a comma-separated list Printed out the data array for sendChairVolunteerList() in email-sent-view and it prints out the appropriate volunteers.
[eluser]Brad K Morse[/eluser]
I resolved the problem of appending the array of data to the $msg variable by looping thru it Not sure if this is the best way to make this work, so I am open to suggestions. Here is the revised email controller function Code: function email() { |
Welcome Guest, Not a member yet? Register Sign In |