0
   if($records->result()>0) 
    {

        foreach ($records->result() as $user)
        {

            $username= ('first name='.$user->u_first_name.'<br/>'.'Last name='.$user->u_last_name.'<br/>'.'Email='.$user->u_email.'<br/>'.'Property Id='.$user->propertyid);
            $username.="<br/>";
            $username.="-------------------------";
            $username.="<br/>";



            $email_template =  file_get_contents($this->config->item('base_url').'assets/email/email.html');
            $email_template = str_replace("[[EMAIL_HEADING]]", $mail_content->subject, $email_template);
            $email_template = str_replace("[[EMAIL_CONTENT]]", $username, $email_template);
            $email_template = str_replace("[[SITEROOT]]", $this->config->item('base_url'), $email_template);
            $email_template = str_replace("[[LOGO]]",$this->config->item('base_url')."assets", $email_template);
            $this->email->message(html_entity_decode($email_template));      
            $this->email->send();
            print_r($email_template);

これは私のコードです

4

1 に答える 1

2

/* アップデート */

テンプレートのビューを通常のように使用して (値を渡す)、3 番目のパラメーターを TRUE に設定して html を返すことができます。

すべてのデータベース レコードを含む 1 つのメールを送信するには、結果オブジェクト全体をビューに渡し、標準の foreach ループなどを使用してビューで処理します。

例えば

if($records->result()>0) {
    $email_template = $this->load->view('email_template', array('heading' => 'My Email Report', 'records' => $records->result(), TRUE);
    $this->email->message($email_template);      
    $this->email->send();
    print_r($email_template);
}

次に、ビュー (/view/email_template) は次のようになります。

<h1><?php echo $heading; ?>
<p> Records;</p>
<table>
<?php
foreach ($records as $r) {
?>
<tr>
    <td><?php echo $r->u_first_name; ?></td>
    <td><?php echo $r->u_last_name; ?></td>
    <td><?php echo $r->u_email; ?></td>
    <td><?php echo $r->propertyid; ?></td>
</tr>
<?php
}
?>
</table>
于 2012-04-10T10:32:50.277 に答える