php - How can i see profile details according to id? -
i trying see profile details there problem getting 'id'. have errors: severity: warning
message: missing argument 1 customers::details() filename: controllers/customers.php and,
a php error encountered
severity: notice
message: undefined variable: id
filename: controllers/customers.php
here 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 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 view page:
... <table class="table table-hover"> <thead> <tr> <th>name</th> <th>surname</th> <th>email</th> </tr> </thead> <?php foreach ($user_data $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> <?}?> ...
try
function detailscustomer($id){ $this->db->where('id', $id); $query = $this->db->get('customers'); return $query->result(); }
you misdeed 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>
Comments
Post a Comment