Created
July 6, 2020 02:29
-
-
Save blogcacanid/34e82ed0f84c269e05c16855c31d5c1b to your computer and use it in GitHub Desktop.
Pegawai.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Controllers; | |
use CodeIgniter\Controller; | |
use App\Models\PegawaiModel; | |
class Pegawai extends Controller | |
{ | |
public function index() | |
{ | |
echo view('layouts/header'); | |
echo view('pegawai'); | |
echo view('layouts/footer'); | |
} | |
public function index1() | |
{ | |
$model = new PegawaiModel(); | |
$data['pegawai'] = $model->orderBy('nip', 'DESC')->findAll(); | |
return view('pegawai', $data); | |
echo view('layouts/header'); | |
echo view('layouts/footer'); | |
echo view('pegawai',$data); | |
} | |
public function find_NIP() | |
{ | |
$nip = $this->request->getVar('nip'); | |
if($this->request->isAJAX()) { | |
$data = ''; | |
$db = \Config\Database::connect(); | |
$builder = $db->table('pegawai'); | |
$qry = $builder->getWhere(['nip' => $nip]); | |
foreach ($qry->getResult() as $row){ | |
$data = array( | |
'nama_pegawai' => $row->nama_pegawai, | |
'alamat' => $row->alamat | |
); | |
} | |
echo json_encode($data); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment