title: CI-4 how to show multiple tables in one page
body: <p>good day all,</p>
  <p>since i'm new in Code Igniter 4 (i was a native PHP self-learner) and i'm new in MVC, my question is how can i show multiple tables in one page ?</p>
  <p>i have a dashboard view with 2 tables inside. one is for display students data and the other is for teachers data. there is no relation between tables, so i can't join the tables.</p>
  <p>i have successfully show one of the table (student or teacher) but i can't show both tables in dashboard at once. i think i have to pass 2 models into controller function but i just can't figure it out how to do it.</p>
  <p>any help will be appreciated</p>
  <p>here is parts of my codes (successfully showing data from 1 table) :</p>
  <p>Controller</p>
  <pre><code>use App\Models\mStudent;
      class Admin extends BaseController
      {
        public function index()
        {
            $model = new mStudent();
            $data['title'] = 'Students';
            $data['getStudents'] = $model-&gt;getStudents();
  
            echo view('admin/header', $data);
            echo view('admin/top_menu');
            echo view('admin/side_menu');
            echo view('admin/dashboard', $data);
            echo view('admin/footer');
        }
  </code></pre>
  <p>Model</p>
  <pre><code>public function getStudents()
            {
              return $this-&gt;findAll();
            }
      
       public function getTeachers()
            {
              return $this-&gt;findAll();
            }
  </code></pre>
  <p>View</p>
  <pre><code>&lt;!-- students table--&gt;
      
              &lt;table class=&quot;table table-bordered text-sm&quot;&gt;
                &lt;thead&gt;
                  &lt;tr&gt;
                    &lt;th style=&quot;width: 10px; text-align: center;&quot;&gt;No&lt;/th&gt;
                    &lt;th style=&quot;text-align: center;&quot;&gt;NAME&lt;/th&gt;
                    &lt;th style=&quot;text-align: center;&quot;&gt;Class&lt;/th&gt;
                  &lt;/tr&gt;
                &lt;/thead&gt;
                &lt;tbody&gt;
                  &lt;?php $no = 1;
                  foreach ($getStudents as $students) { ?&gt;
                    &lt;tr&gt;
                      &lt;td&gt;&lt;?= $no; ?&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;?= $students['name'] ?&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;?= $students['class'] ?&gt;&lt;/td&gt;
                    &lt;/tr&gt;
                  &lt;?php $no++;
                  } ?&gt;
                &lt;/tbody&gt;
              &lt;/table&gt;
  
          
      &lt;!-- teacher table--&gt;
      
              &lt;table class=&quot;table table-bordered text-sm&quot; id=&quot;defaulttable&quot;&gt;
                &lt;thead&gt;
                  &lt;tr&gt;
                    &lt;th style=&quot;width: 10px; text-align: center;&quot;&gt;No&lt;/th&gt;
                    &lt;th style=&quot;text-align: center;&quot;&gt;NAME&lt;/th&gt;
                    &lt;th style=&quot;text-align: center;&quot;&gt;ID&lt;/th&gt;
                  &lt;/tr&gt;
                &lt;/thead&gt;
                &lt;tbody&gt;
                  &lt;?php $no = 1;
                  foreach ($getTeachers as $teachers) { ?&gt;
                    &lt;tr&gt;
                      &lt;td&gt;&lt;?= $no; ?&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;?= $teachers['name'] ?&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;?= $teachers['id'] ?&gt;&lt;/td&gt;
                    &lt;/tr&gt;
                  &lt;?php $no++;
                  } ?&gt;
                &lt;/tbody&gt;
              &lt;/table&gt;
  </code></pre>