title: codeigniter passing count_all_results to view
body: <p>I'm using the count_all_results() function to return a user's number of languages spoken. But when I try to pass the number to the view, I keep getting a php undefined variable (for $lang_cnt). Below is my code:</p>
  
  <p><strong>Model</strong></p>
  
  <pre><code>function countLanguages($id) {
  
      $this-&gt;db-&gt;where('user_id', $id)-&gt;from('languages');
      return $this-&gt;db-&gt;count_all_results();
  }
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>function showLangCount() {
  
      $data['lang_cnt'] = $this-&gt;language_model-&gt;countLanguages($id);
  
      $this-&gt;load-&gt;view('lang_view', $data);
  }
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>&lt;p&gt;This user speaks &lt;?php echo $lang_cnt; ?&gt; languages.&lt;/p&gt;
  </code></pre>