title: Codeigniter Database Values Not Showing In View
body: <p>I have encountered an issue where the data from my database is not showing in my view. As far as I'm aware, my Controller, Model and View are set up correctly. I've done this before so I know what's needed, but I can't locate my old file. I hope you guys can help?</p>
  
  <p>Controller:</p>
  
  <pre><code>&lt;?php
  if(!defined('BASEPATH')) exit('Hacking Attempt: Get out of the system ..!');
  
  class C_Live extends CI_Controller
  {    
  
  function C_Live(){
      parent::__construct();
      $this-&gt;load-&gt;model('M_live');
  }
  
  public function index(){
    $query = $this-&gt;M_live-&gt;getUpgrades();
    if(isset($query)){
        $data['upgrades'] = $query;
    }
    $this-&gt;load-&gt;view('Test', $data);
   } 
  }
  
  ?&gt; 
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>&lt;?php
  if(!defined('BASEPATH')) exit('Hacking Attempt: Get out of the system ..!');
  
  class M_live extends CI_Model
  {
    function M_live()
    {
      parent::Model();
    }
  
    function getUpgrades()
    {
      $query = $this-&gt;db-&gt;get('live_client_trust_versions');
      // Produces: SELECT * FROM client_trust_versions
      return $query-&gt;num_rows() &gt; 0  $query-&gt;result() : NULL;
    }
  }
  ?&gt;
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>&lt;table&gt;
      &lt;tr&gt;
          &lt;th&gt;ID&lt;/th&gt;
          &lt;th&gt;Client Name&lt;/th&gt;
          &lt;th&gt;App Server&lt;/th&gt;
          &lt;th&gt;Instance Name&lt;/th&gt;
          &lt;th&gt;BankStaff Server&lt;/th&gt;
          &lt;th&gt;SQL Server&lt;/th&gt;
          &lt;th&gt;Instance&lt;/th&gt;
          &lt;th&gt;Health Roster Version&lt;/th&gt;
          &lt;th&gt;Employee Online Version&lt;/th&gt;
          &lt;th&gt;Roster Perform&lt;/th&gt;
          &lt;th&gt;BankStaff Version&lt;/th&gt;
          &lt;th&gt;SafeCare Version&lt;/th&gt;
          &lt;th&gt;E-Expenses&lt;/th&gt;
      &lt;/tr&gt;
  
      &lt;?php
  if(isset($upgrades)){
  //If no rows were found $upgrades will be NULL and isset() will return false. 
  //Therefore, you never try to address an undefined variable.  
    foreach($upgrades as $upgrade){?&gt;
  
          &lt;tr&gt;
          &lt;td&gt;&lt;?php=$upgrade-&gt;ID;?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php=$upgrade-&gt;Client_Name?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php=$upgrade-&gt;App_Server?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php=$upgrade-&gt;Instance_Name?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php=$upgrade-&gt;BankStaff_Server?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php=$upgrade-&gt;SQL_Server;?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php=$upgrade-&gt;Instance;?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php=$upgrade-&gt;Health_Roster_Version;?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php=$upgrade-&gt;Employee_Online_Version;?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php=$upgrade-&gt;Roster_Perform_Version;?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php=$upgrade-&gt;BankStaff_Version;?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php=$upgrade-&gt;SafeCare_Version;?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php=$upgrade-&gt;E-Expenses;?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;?php }}?&gt;
  &lt;/table&gt;  
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/FCEkz.png" rel="nofollow">The result I'm getting in my view.</a>     </p>