show tables from different sql tables that unrelated

i want to show 2 tables that contain diffent information in a single codeigniter view page

heres the code on model.php (they are in the same class

> public function showPlants(){
> return $this->db->get('plantsdata');
> }
> 
> public function showAnimals(){
> return $this->db->get('animalsdata');
> }

the code on controller.php

> public function plantsandanimals() {
> $data = [
> 'finaldata'=>$this->db->showPlants()->result()
> ];
> $data = [
> 'finaldata'=>$this->db->showAnimals()->result()
> ];
> $this->load->view('viewplantsandanimal',$data);
> }

and then the viewplantsandanimals.php

<table>
<?php foreach ($finaldata as $here) { ?>
<tr>
<td> <?= $here->animalsname
</td>
<?php }; ?>
<tr>
</table>


<table>
<?php foreach ($finaldata as $here) { ?>
<tr>
<td> <?= $here->plantsname
</td>
<?php }; ?>
<tr>
</table>

that so i can have two tables to show animals and plants. but every tutorial on google either

  1. join the table
  2. make the plants table looping until have 9 data (animals has 9 records and plants has 3)

  • Simply merge the result of both queries or assign them to separate keys in the $data array. If you don’t know the basics, getting your hands dirty on a framework directly is bad start!

    – 




  • 1. this is a homework 2. i dont want to learn framework either 3. i still dont understand what you mean by that because that is literally what i did

    – 




Leave a Comment