adeeva

join 3 table

Dec 19th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. //Controller
  2.  
  3. <?php
  4. defined('BASEPATH') OR exit('No direct script access allowed');
  5.  
  6. class Karyawan extends CI_Controller {
  7.  
  8. function __construct(){
  9. parent:: __construct();
  10. $this->load->model(array('m_karyawan','m_kontrak','m_keluarga','m_anak','m_pengalaman'));
  11. $this->load->library(array('upload'));
  12. }
  13. public function index()
  14. {
  15. $isi['content']='karyawan/f_eks_karyawan';
  16. $isi['data']= $this->m_karyawan->tampil_eks_karyawan()->result();
  17. $this->load->view('template',$isi);
  18. }
  19.  
  20. }
  21.  
  22.  
  23.  
  24.  
  25. //Model
  26. <?php
  27. defined('BASEPATH') OR exit('No direct script access allowed');
  28.  
  29. class M_karyawan extends CI_model {
  30.  
  31. public function tampil_eks_karyawan(){
  32. $query=$this->db->join('tb_kontrak k','k.id_karyawan=d.id_karyawan')->join('tb_nonaktif n','n.id_karyawan=d.id_karyawan')->where('d.aktif'=0)->get('tb_karyawan d');
  33. return $query;
  34. }
  35. }
  36.  
  37.  
  38. //view
  39.  
  40.  
  41. <table class="table table-striped table-bordered table-hover table-full-width" id="sample_1">
  42. <thead>
  43. <tr>
  44. <th width="60">No</th>
  45. <th width="120">Foto</th>
  46. <th width="230">Nama</th>
  47.  
  48.  
  49. <th width="150">Jabatan</th>
  50.  
  51. </tr>
  52. </thead>
  53. <tbody>
  54. <?php $no=1;
  55. foreach ($data as $r) { ?>
  56. <tr>
  57. <td><?php echo $no++; ?></td>
  58.  
  59. <td><?php echo $r->nama_karyawan; ?></a></td>
  60.  
  61. <td><?php echo $r->jabatan_karyawan; ?></td>
  62.  
  63.  
  64. </tr>
  65. <?php } ?>
  66. </tbody>
  67. </table>
Advertisement
Add Comment
Please, Sign In to add comment