2012-07-09 54 views
0

我要顯示我的查詢結果到我這樣的sendmail控制器:顯示查詢結果存入發送郵件控制器

控制器

function contact() 
{ 
    $data['email'] = $this->Pgallery_model->get_Email(); 
      $config['protocol'] = 'sendmail'; 

      $this->email->initialize($config); 

      $this->email->to(/*here query result*/); 

      $this->email->send();    
      $this->load->view('contact_success', $data); 
    } 

型號

function get_Email() 
{ 
    $query = $this->db->query('select email from setup'); 
    return $query->result(); 
} 

如何讓查詢到我的交付郵件? 謝謝

回答

0

爲了得到你應該使用查詢結果:

$result = $this->db->result(); 

這將讓你的對象那麼你將不得不做這樣的事情:

echo $result->email; 

我會喜歡向你指出,使用camelcase AND下劃線大多是不好的做法。

get_Email() should either be getEmail() or get_email() 
+0

你能告訴我更具體嗎?因爲我嘗試了你的建議,而且根本沒有改變。我只是想要這封電子郵件到'$ this-> email->(/ *這裏查詢結果* /);'是動態的,我可以用另一封電子郵件進行更改。謝謝 – ranggadablues 2012-07-16 03:54:47

+0

你現在的結果是什麼,你期望什麼?我編輯了我的答案 – WiseStrawberry 2012-07-16 08:14:29