我遇到错误“消息:未定义的变量:帖子”。这是在我使用codeigniter电子邮件发送电子邮件后收到的。
我需要通过CI电子邮件发送html输出。
有人吗?感谢进阶!
控制器
function email(){
$this->load->library('email');
$config = array (
'mailtype' => 'html',
'wordwrap'=> TRUE,
'charset' => 'utf-8',
'priority' => '1'
);
$this->email->initialize($config);
$this->email->from('mywebsite.com', 'My website');
$this->email->to('sender@gmail.com');
$this->email->subject('Test');
$data = $this->data['posts'] = $this->paypal->getRows();
$message = $this->load->view('Receipt','$data',true);
$this->email->message($message);
$this->email->send();
}
View(Receipt.php)-我想通过电子邮件发送的视图
<?php
foreach($posts as $row){
$row->room_type;
}
?>
答案 0 :(得分:0)
查看如何将数据从控制器传递到视图
$data['posts'] = $this->paypal->getRows();
$message = $this->load->view('Receipt',$data,true);
将数组分配给视图时不需要在视图中显示
。