douya1974 2014-01-31 14:14
浏览 89
已采纳

我如何根据id查看个人资料详细信息?

I am trying to see profile details but there is a problem about getting 'id'. But I have some errors: Severity: Warning

Message: Missing argument 1 for customers::details() Filename: controllers/customers.php And,

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: id

Filename: controllers/customers.php

Here is my model:

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');

}

Here is my controller:

    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');
     }
 }

Here is my view page:

...
    <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> <?}?>  

    ...
  • 写回答

1条回答 默认 最新

  • doure5236 2014-01-31 16:48
    关注

    try this

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

    you misdeed to add return $query->result();

    also in view

    change

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

    into

           <td><a href='http://localhost/CRM/customers/details/<?php echo $row->id;?>' type='button' class='btn btn-info'>Details</a></td>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器