Skip to content

Instantly share code, notes, and snippets.

@rohman
Created April 16, 2013 10:20
Show Gist options
  • Save rohman/5394859 to your computer and use it in GitHub Desktop.
Save rohman/5394859 to your computer and use it in GitHub Desktop.
Belajar TypeHead Bootstrap CI
<?php
class Tamu extends CI_Controller
{
public $data;
function __construct()
{
parent::__construct();
}
function cari()
{
$this->load->helper('url');
$this->load->view('tamu_cari', $this->data);
}
function searchTamu()
{
$this->load->model('tamu_model');
$nama = $this->input->post('nama');
$limit = $this->input->post('limit');
$getTamu = $this->tamu_model->cariTamu($nama, $limit);
$res = array();
if(!empty($getTamu))
{
foreach($getTamu->result() as $row)
{
$res[] = array('label' => $row->id, 'value' => $row->nama);
}
}
else
{
$res[] ="";
}
echo json_encode($res);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment