Welcome Guest, Not a member yet? Register   Sign In
how to display count_all_results record to view

Hi I am having trouble echoing a count to my view.

Please help. I am trying to count the number of subjects in the database.


PHP Code:
  public function Gettotsubjects($session_id$section_id$class_id
        return $this->db->count_all_results('ftscores_primary');


PHP Code:
  public function Gettotsubjects($session_id$section_id$class_id)
    $data $this->ftprimary_model->Gettotsubjects($session_id$section_id$class_id); 
    return $data->subject_id;


PHP Code:
<?php echo $CI->Gettotsubjects($value->session_id$value->section_id$value->class_id);?>

Nothing shows in the view even though it works well when I test in the Controller


What version of CI are you using (3.x or 4.x)?

(12-15-2020, 02:02 PM)php_rocs Wrote: @EseMiami,

What version of CI are you using (3.x or 4.x)?

I'm using CI_VERSION = '3.1.6'

I'm sorry but your code doesn't make a lot of sense. The model return count_all_results but the controller return subject_id???
Also, instead of the controller displaying the view, it's the other way around and your view is calling your controller?
There must be missing code you have not post...
Or maybe what you call a controller is a library, but still, you return the count and display the id...
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/

Theme © iAndrew 2016 - Forum software by © MyBB