Welcome Guest, Not a member yet? Register   Sign In
i am a codeigniter biginner, i have two files in my view folder. logged _in_ area.php and personal_emp .php. design is
#1

[eluser]atulswe1[/eluser]
i got the error undifined index:id and name,,all of


views
1.logged_in_area

Code:
<table border="1" height="200" width="200" bordercolor="#003366" align="center">
      <tr><th>ID</th></td><th>NAME</th>&lt;?php /*?&gt;<th>Fathet Name</th><th>Dob</th><th>Qualification</th><th>Identity Type</th><th>Identity No</th><th>Gender</th><th>Email</th><th colspan='2'>Action</th>&lt;?php */?&gt;</tr>
   &lt;?php
      foreach($rows as $r)
  
{
   echo "<tr>";
   echo "<td>". $r->id ."</td>";
   echo "<td>". anchor('employee/abc/',$r->name) ."</td>";
  
   echo "</tr>";
   echo "<br>";
}
   ?&gt;
   </table>


2.personal_emp


Code:
<table border="1" height="200" width="200" bordercolor="#003366" align="center">
      <tr><th>ID</th></td><th>NAME</th><th>Fathet Name</th><th>Dob</th><th>Qualification</th><th>Identity Type</th><th>Identity No</th><th>Gender</th><th>Email</th><th colspan='2'>Action</th></tr>
   &lt;?php
      foreach($rows as $r)
  
{
   echo "<tr>";
   echo "<td>". $r['id'] ."</td>";
   echo "<td>". $r['name'] ."</td>";
   echo "<td>". $r['father_name'] ."</td>";
   echo "<td>". $r['dob'] ."</td>";
   echo "<td>". $r['qualification'] ."</td>";
   echo "<td>". $r['identity_type'] ."</td>";
   echo "<td>". $r['identity_no'] ."</td>";
   echo "<td>". $r['gender'] ."</td>";
   echo "<td>". $r['email'] ."</td>";
   echo "<td>". anchor('employee/input/'.$r['id'],'Edit') ."</td>";
   echo "<td>". anchor('employee/del/'.$r['id'],'Delete') ."</td>";
   echo "</tr>";
   echo "<br>";
}
   ?&gt;
   </table>

controller

Code:
function abc($id = 0)
     {
      $this->load->helper('form');
   $this->load->helper('html');
   $this->load->model('emp_model');
      $data['rows']=$this->emp_model->general();  
  
   $data['rows'] = $this->emp_model->info1($id);
    
   $this->load->view('personal_emp',$data);
     }


model


Code:
function info1($id)
    {
    $this->load->database();  
    $query = $this->db->get_where('employee',array('id'=>$id));
    return $query->row_array();        
    }
#2

[eluser]kreamik[/eluser]
you got single data from model with row_array() and you extract data in your view like an array ..

just vardump($rows) on the top of your view to know what is inside $rows ...




Theme © iAndrew 2016 - Forum software by © MyBB