'Merge 2 tables in one field ci 3

I have a problem with my application, I want to display Permissions, Late and Present descriptions. my problem i can't display "Permission" status on my form table because my permission description is stored in a different table.

following the table absen_pagi

I want to create a table like this that combines 2 tables the form you want to create

and here is my code which only displays data for 1 table from absent_pagi

     $absen = $this->db->query ("SELECT DISTINCT waktu,status from absen_pagi where nip='".$data['nip']."' AND opd='$opd' AND  MONTH(waktu) ='$timestamp'")->result_array();
  foreach ($tampiltgl as $tampiltgldata) {
                $celldata = 'A';
                $color;
                foreach ($absen as $key) {
                    if ($tampiltgldata['waktu'] == $key['waktu']) {
                        $celldata = $key['status'];
                        
                        break;
                    }
                }
                 if($celldata == 'A'){
            $bgcolor="red";
      } elseif ($celldata == 'HADIR'){
            $bgcolor="green";
      }elseif ($celldata == 'TERLAMBAT'){
            $bgcolor="yellow";
      }
                echo "<td bgcolor=$bgcolor align=center >$celldata</td>";
            }
            ?>
            <?php
                        foreach ($hadir as $key2) :?>
  <td align=center><?php echo $key2['COUNT(*)']; ?> </td>
  <?php endforeach; ?> 
        </tr>
    <?php endforeach; ?>
    
</tbody>
  </table>               

can you guys help me?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source