Assalam,.. Karena sikolag dan siaselah memiliki database yang berbeda, atau terdiri dari 2 database maka sikolag mesti dijadikan konek ke 2 database, buka file "application/config/database.php" cari koneksi database : $active_group = 'default'; $query_builder = TRUE; $db['default'] = array( 'dsn' => '', 'hostname' => 'localhost', 'username' => 'root', 'password' => '', 'database' => 'siaselah_db', 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => FALSE, 'db_debug' => (ENVIRONMENT !== 'production'), 'cache_on' => FALSE, 'cachedir' => '', 'char_set' => 'utf8', 'dbcollat' => 'utf8_general_ci', 'swap_pre' => '', 'encrypt' => FALSE, 'compress' => FALSE, 'stricton' => FALSE, 'failover' => array(), 'save_queries' => TRUE ); lalu ubah menjadi : $active_group = 'default'; $query_builder = TRUE; $db['default'] = array( 'dsn' => '', 'hostname' => 'localhost', 'username' => 'root', 'password' => '', 'database' => 'database_sikolag', 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => FALSE, 'db_debug' => TRUE, 'cache_on' => FALSE, 'cachedir' => '', 'char_set' => 'utf8', 'dbcollat' => 'utf8_general_ci', 'swap_pre' => '', 'encrypt' => FALSE, 'compress' => FALSE, 'stricton' => FALSE, 'failover' => array(), 'save_queries' => TRUE ); $db['siaselah'] = array( 'dsn' => '', 'hostname' => 'localhost', 'username' => 'root', 'password' => '', 'database' => 'database_siaselah', 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => FALSE, 'db_debug' => TRUE, 'cache_on' => FALSE, 'cachedir' => '', 'char_set' => 'utf8', 'dbcollat' => 'utf8_general_ci', 'swap_pre' => '', 'encrypt' => FALSE, 'compress' => FALSE, 'stricton' => FALSE, 'failover' => array(), 'save_queries' => TRUE ); untuk menampilkan data nanti jadi begini : <?php defined('BASEPATH') OR exit('No direct script access allowed'); private $db2; public function __construct(){ parent::__construct(); $this->db2 = $this->load->database('siaselah', TRUE); } function jadwal(){ // Silahkan sesuaikan dengan query jadwal $data['jadwal'] = $this->db2->query("SELECT * FROM rb_jadwal_pelajaran"); $this->template->load(template().'/template',template().'/jadwal_pelajaran',$data); } ?> Viewsnya begini : <table class="table table-bordered table-striped"> <thead> <tr> <th style='width:20px'>No</th> <th>Jadwal Pelajaran</th> <th>Kelas</th> <th>Guru</th> <th>Hari</th> <th>Mulai</th> <th>Selesai</th> <th>Ruangan</th> </tr> </thead> <tbody> <?php foreach ($jadwal->result_array() as $r) { echo "<tr><td>$no</td> <td>$r[namamatapelajaran]</td> <td>$r[nama_kelas]</td> <td>$r[nama_guru]</td> <td>$r[hari]</td> <td>$r[jam_mulai]</td> <td>$r[jam_selesai]</td> <td>$r[nama_ruangan]</td> </tr>"; $no++; } ?> <tbody> </table> Selesai, semoga bermanfaat,.. ^_^
|