Cara Looping Horizontal

Maaf teman2, judulnya bingung mau pakai judul apa :D. Jadi gini ceritanya. Saya punya tabel jadwal KBM seperti di bawah ini

tabel jadwal kbm

Berikut ini tabel di databasenya

tabel jadwal kbm database

Berikut ini adalah kode querynya

public function search_jadwal($hari,$semes,$tahun) {
		$this->db->select('*');
		$this->db->from('tb_jadwal');
		$this->db->join('tb_mapel', 'tb_mapel.mapel_id = tb_jadwal.jadwal_mapelid');
		$this->db->join('tb_kelas', 'tb_kelas.id = tb_jadwal.jadwal_kelasid');
		$this->db->join('tb_hari', 'tb_hari.hari_id = tb_jadwal.jadwal_hari');
		$this->db->join('tb_dewan_guru', 'tb_dewan_guru.guru_kode = tb_jadwal.jadwal_guruid');
		$this->db->where(['jadwal_ta' => $tahun, 'jadwal_sms' => $semes, 'jadwal_hari' => $hari]);
		$this->db->order_by('jadwal_jam_start', 'ASC');
		return $this->db->get()->result_array();
	}

Berikut ini kode untuk viewnya

<div class="table table-responsive">
                      <table class="table table-bordered table-striped">
                        <thead>
                          <tr>
                            <th rowspan="4" class="align-middle">No</th>
                            <th rowspan="4" class="align-middle">Nama Guru</th>
                            <th rowspan="4" class="align-middle">Kode/Id</th>
                            <th colspan="35" class="text-center">Jam KBM Ke-</th>
                          </tr>
                          <tr class="text-center">
                            <th colspan="3">1</th>
                            <th colspan="3">2</th>
                            <th colspan="3">3</th>
                            <th colspan="3">4</th>
                            <th colspan="3">5</th>
                          </tr>
                          <tr class="text-center">
                            <th colspan="3">07.30-08.40</th>
                            <th colspan="3">08.40-09.50</th>
                            <th colspan="3">10.50-12.00</th>
                            <th colspan="3">13.15-14.15</th>
                            <th colspan="3">14.15-15.15</th>
                          </tr>
                          <tr class="text-center">
                            <th>Kelas</th>
                            <th>Mapel</th>
                            <th>Ceklis</th>
                            <th>Kelas</th>
                            <th>Mapel</th>
                            <th>Ceklis</th>
                            <th>Kelas</th>
                            <th>Mapel</th>
                            <th>Ceklis</th>
                            <th>Kelas</th>
                            <th>Mapel</th>
                            <th>Ceklis</th>
                            <th>Kelas</th>
                            <th>Mapel</th>
                            <th>Ceklis</th>
                          </tr>
                        </thead>
                        <tbody>
                          <?php $i = 1; ?>
                          <?php foreach($lijad as $lj): ?>
                            <tr>
                              <td><?php echo $i; ?>.</td>
                              <td><?php echo $lj['guru_nama']; ?></td>
                              <td><?php echo $lj['jadwal_guruid']; ?></td>
                              <?php if($lj['jadwal_jam_start'] == '07:30' AND $lj['jadwal_jam_end'] == '08:40') { ?>
                                <td><?php echo $lj['kelas']; ?></td>
                                <td><?php echo $lj['mapel_nama']; ?></td>
                                <td>H/S/I/A</td>
                              <?php }else if($lj['jadwal_jam_start'] == '08:40' AND $lj['jadwal_jam_end'] == '09:50') { ?>
                                <td><?php echo $lj['kelas']; ?></td>
                                <td><?php echo $lj['mapel_nama']; ?></td>
                                <td>H/S/I/A</td>
                              <?php }else if($lj['jadwal_jam_start'] == '10:50' AND $lj['jadwal_jam_end'] == '12:00') { ?>
                                <td><?php echo $lj['kelas']; ?></td>
                                <td><?php echo $lj['mapel_nama']; ?></td>
                                <td>H/S/I/A</td>
                              <?php }else if($lj['jadwal_jam_start'] == '13:15' AND $lj['jadwal_jam_end'] == '14:15') { ?>
                                <td><?php echo $lj['kelas']; ?></td>
                                <td><?php echo $lj['mapel_nama']; ?></td>
                                <td>H/S/I/A</td>
                              <?php }else { ?>
                                <td><?php echo $lj['kelas']; ?></td>
                                <td><?php echo $lj['mapel_nama']; ?></td>
                                <td>H/S/I/A</td>
                              <?php } ?>
                            </tr>
                          <?php $i++; ?>
                          <?php endforeach; ?>
                        </tbody>
                      </table>
                    </div>

Nah pertanyaannya adalah bagaimana caranya, agar guru yg memiliki jadwal lebih 1, data nya looping ke samping sesuai dengan jadwal yg ada di tabel jadwal KBM dengan cara mengecek jadwal kbm dia yg ada di tabel database.

Mohon pencerahannya, terima kasih.

avatar Ahmad554
@Ahmad554

95 Kontribusi 39 Poin

Dipost 3 tahun yang lalu

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban