我试图从数据库回显控制器中的记录我基本上想要发送邮件但我无法在控制器中回显记录
控制器代码
function sendmail(){
$email = $this->input->post('email');
$this->load->model('m_login');
$email=$this->m_login->search_mail_data($email);
}
模型
function search_mail_data($email){
$this->db->select('user_id, username, password');
$this->db->from('login');
$this->db->where('username', $email);
$query = $this->db->get();
if($query->num_rows() == 1) {
return $query->result(); //if data is true
} else {
return false; //if data is wrong
}
答案 0 :(得分:1)
控制器
function sendmail(){
$email = $this->input->post('email');
$this->load->model('m_login');
$result=$this->m_login->search_mail_data($email);
print_r($result); //print result
}
模型
function search_mail_data($email=""){
$this->db->select('user_id, username, password');
$this->db->from('login');
$this->db->where('username', $email);
$query = $this->db->get();
if($query->num_rows() == 1) {
return $query->result(); //if data is true
} else {
return false; //if data is wrong
}
答案 1 :(得分:0)
试试这个:
function sendmail(){
$email = $this->input->post('email');
$data = $this->load->model('m_login');
var_dump($data)
}
答案 2 :(得分:0)
亲爱的朋友试试这段代码 在控制器
function sendmail(){
$email = $this->input->post('email');
$this->load->model('m_login');
$email=$this->m_login->search_mail_data($email);
foreach($email as $data)
{
echo $data->id;//echo whatever data you want
}
}