2017-08-09 13 views
0

CodeIgniterを使用してデータベース内のデータを更新したい!私Codeigniter foreach未定義の変数Update Data In

$id = $this->uri->segment(3); 
    $data['user'] = $this->authentication->show_students(); 
    $data['single_user'] = $this->authentication->show_student_id($id); 

ライブラリ

function show_students(){ 
    $query = $this->ci->db->get('users'); 
    $query_result = $query->result(); 
    return $query_result; 
} 
function show_student_id($data){ 
    $this->ci->db->select('*'); 
    $this->ci->db->from('users'); 
    $this->ci->db->where('id', $data); 
    $query = $this->ci->db->get(); 
    $result = $query->result(); 
    return $result; 
} 
+0

認証ライブラリをロードしましたか? –

+1

実際の問題を説明できますか? –

+0

I load パブリック関数__construct() { parent :: __ construct(); $ this-> load-> helper(array( 'form'、 'url')); $ this-> load-> library( 'authentication'); } – deadd1wer

答えて

0

問題

ビュー

<?php foreach ($single_user as $user): ?> 

コントローラは、コントローラに

$this->load->view('your_view', $data); 
をこの式を追加してみています

$id = $this->uri->segment(3); 
$data['user'] = $this->authentication->show_students(); 
$data['single_user'] = $this->authentication->show_student_id($id); 
$this->load->view('your_view', $data); 

うまくいけば、それはあなたを助けます:

あなたのコードは、これを好む必要があります。