Quantcast
Channel: Active questions tagged return-value - Stack Overflow
Viewing all articles
Browse latest Browse all 228

CodeIgniter model method not returning value to controller

$
0
0

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:

Model

function countLanguages($id, $cnt_languages) {    $this->db->where('user_id', $id)->from('languages');    $cnt_languages = $this->db->count_all_results();}

Controller

function showLangCount() {    $data['lang_cnt'] = $this->language_model->countLanguages($cnt_languages);    $this->load->view('lang_view', $data);}

View

<p>This user speaks <?php echo $lang_cnt; ?> languages.</p>

Viewing all articles
Browse latest Browse all 228

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>