我无法使用php codeigniter

时间:2017-02-02 09:29:30

标签: php codeigniter-3

我是新来的代码点火器我无法解决这个问题请帮助我 下面的代码在

  

模型中的select.php

//     update for selected data
public function update_analytics_id1()
    {
    $this->db->where('google_analytics', $id);
    $this->db->update('seo', $data);

}

public function show_all_analytics(){
    $query = $this->db->get('seo');
    $query_result = $query->result();
    return $query_result;
}
//single data fetch
public function show_single_id{
    this->db->select('*');
    $this->db->from('seo');
    $this->db->where('google_analytics', $data);
    $query = $this->db->get();
    $result = $query->result();
    return $result;

}
  

user_authentication.php是控制器

 public function update(){  
    $id= $this->input->post('did');
    $data = array('a_analytics' =>$this->input->post('analytics') );
    $this->load->model('select');
                  //update query
    $this->select->update_analytics_id1($id,$data);
    $this->show_analytics_id();
}

public function show_analytics_id(){
    $this->load->model('select');
    $id = $this->uri->segment(2);
    $data['seo'] = $this->select->show_all_analytics();
    $data['single_entry'] = $this->select->show_single_id($id);
    $this->load->view('showdata', $data);
}
  

showdata是我的观看页面

 <?php include 'header.php'; ?>

        <!-- Fetching All Details of Selected data From Database And Showing In a Form -->
        <?php foreach ($seo as $single_entrys): ?>
    <div class="form">
        <form action="<?php echo base_url ('User_Authentication/update'); ?>" method="post">
            <input type="text" id="hide" name="did" value="<?php echo $id->id; ?>">
            <label>GOOGLE ANALYTICS</label>
                <textarea name="analytics" id="google">
                   <?php echo $seo->google_analytics; ?>                    
                </textarea>
            <input type="submit" name="submit" value="add">
        </form>  
    </div>   
 

*当我尝试运行il时遇到了PHP错误

严重性:注意

消息:未定义的变量:seo

文件名:views / showdata.php

行号:4

回溯:*

1 个答案:

答案 0 :(得分:0)

您必须从控制器

将数据传递给模型函数
  

控制器代码

//update query

$this->load->model('select');
$this->select->update_analytics_id1($id,$data);
  

Select.php(Model)

// update for selected student 

    public function update_analytics_id1($id=NULL, $data=NULL)
    {
        $this->db->where('google_analytics', $id);
        $this->db->update('seo', $data);

    }

   public function show_all_analytics()
   {
    $this->db->select("*");
    $this->db->from("seo");
    $query = $this->db->get()->result_array();
    if(!empty($query) && isset($query))
    {
        return $query ;
    }
    else
    {
        return FALSE ;
    }
}

    //single data fetch
    public function show_single_id($data=NULL)
    {
        this->db->select('*');
        $this->db->from('seo');
        $this->db->where('google_analytics', $data);
        $query = $this->db->get();
        $result = $query->result();
        return $result;

    }

获取更多帮助codeigniter MySQL