2014-01-31 126 views
0

我想查看個人資料的詳細信息,但存在關於獲取「ID」的問題。但我有一些錯誤:嚴重性:警告如何根據ID查看個人資料詳細信息?

消息:缺少爲客戶::細節() 文件名參數1:控制器/ customers.php 而且,遇到

一個PHP錯誤

嚴重性:通知

消息:未定義變量:ID

文件名:控制器/ customers.php

這裏是我的模型:

function selectCustomer(){ 

    $this->db->select('*'); 
    $this->db->from('customers'); 

    $query = $this->db->get(); 

    return $query->result(); 
} 
function detailsCustomer($id){ 
    //$id= $_GET['ID']; 
    //$this->db->select('*'); 
    //$this->db->from('customers'); 
    $this->db->where('ID', $id); 
    $query = $this->db->get('customers'); 

} 

這裏是我的控制器:

publicfunction viewCustomers(){ 
    $this->load->model('CustomerModel'); 
    $result = $this->CustomerModel->selectCustomer(); 
    return $result;} 

    public function details($id){ 

    $this->load->model('CustomerModel'); 

    $data["result"] = $this->CustomerModel->detailsCustomer($id); 

     if($this->session->userdata('logged_in')){ 
     error_reporting(0); 
     $session_data = $this->session->userdata('logged_in'); 
     $data1['email'] = $session_data['email']; 
     $this->load->view('navbarview', $data1); 
     $this->load->view('Detailsview',$data); 
    }else{ 
     redirect('home', 'refresh'); 
    } 
} 

這是我的看法頁:

... 
    <table class="table table-hover"> 
     <thead> 
     <tr> 
      <th>Name</th> 
      <th>Surname</th> 
      <th>Email</th> 
     </tr> 
     </thead> 
        <?php foreach ($user_data as $row) { 
       echo "  
     <table class='table table-hover'> 
     <tbody> 
     <tr> 
      <td>".$row->name."</td> 
      <td>".$row->surname."</td> 
      <td>".$row->email."</td>";?> 


      <td><a href='http://localhost/CRM/customers/details/<?php echo $id;?>' type='button' class='btn btn-info'>Details</a></td> 
     <td><a href='Editview.php' data-toggle='modal' class='btn btn-success'>Edit</a></td> 
    </tr> 
    </tbody> 
</table> <?}?> 

    ... 
+0

你有一個公共的功能的詳細信息($ ID){ 這哪裏是叫什麼? – Mazzy

+0

基本上你沒有將一個ID傳遞給details方法。嘗試在調用細節方法之前嘗試var_dump $ id並查看它是否正確 –

回答

1

試試這個

function detailsCustomer($id){ 
    $this->db->where('ID', $id); 
    $query = $this->db->get('customers'); 
    return $query->result(); 
} 

你劣跡添加返回$ query- >結果();

也鑑於

變化

 <td><a href='http://localhost/CRM/customers/details/<?php echo $id;?>' type='button' class='btn btn-info'>Details</a></td> 

 <td><a href='http://localhost/CRM/customers/details/<?php echo $row->id;?>' type='button' class='btn btn-info'>Details</a></td> 
+0

非常感謝,現在正在工作!:) – user3075283

相關問題