title: codeigniter error :Message: Undefined variable: results
body: <p>I am adding users in a table through <code>CodeIgniter</code> form. <code>Insertion</code> is going fine. but after deleting selected record i am getting <strong>undefined variable results</strong>.
  I also defined</p>
  
  <pre><code> $results = NULL;
  </code></pre>
  
  <p>in my controller code.
  What is happening with my code?</p>
  
  <p><strong>Controller code</strong></p>
  
  <pre><code>$results = NULL;
  $this-&gt;load-&gt;model('User');
  $form_data['results'] = $this-&gt;User-&gt;view_table();
  $this-&gt;load-&gt;view('User/User_login', $form_data);
  </code></pre>
  
  <p><strong>View Code  in user_login.php</strong></p>
  
  <pre><code>&lt;?php 
              if(sizeof($results)&gt;0){
                  foreach ($results as $row){
                      echo "&lt;tr style='text-align:center';&gt;";
                      echo "&lt;td&gt;".$id=$row-&gt;id."&lt;/td&gt;";
                      echo "&lt;td&gt;".$row-&gt;first_name."&lt;/td&gt;";
                      echo "&lt;td&gt;".$row-&gt;last_name."&lt;/td&gt;";
                      echo "&lt;td&gt;".$row-&gt;username."&lt;/td&gt;";
                      echo "&lt;td&gt;".$row-&gt;email."&lt;/td&gt;";
                      echo "&lt;td&gt;&lt;a href = ".base_url().'Users/user_edit'."&gt;Edit&lt;/a&gt;|&lt;a href=".base_url().'Users/user_delete/'.$id=$row-&gt;id."&gt;Delete&lt;/a&gt;&lt;/td&gt;";
                     // echo $id; die();
                  echo "&lt;/tr&gt;";
              }
              }else{
                  echo "no record found";
              }
  
              ?&gt;
  </code></pre>
  
  <p><strong>Error</strong></p>
  
  <pre><code>A PHP Error was encountered
  
  Severity: Notice
  
  Message: Undefined variable: results
  
  Filename: User/User_login.php
  
  Line Number: 44
  </code></pre>