Willy23

Controller Admin (Autocomplete)

Jan 12th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.12 KB | None | 0 0
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2.  
  3. class Admin extends CI_Controller {
  4.  function __construct(){
  5.         parent::__construct();
  6.         if($this->session->userdata('id_user') <> '1'){
  7.             redirect('login');
  8.         }
  9.     }
  10.     public $layout = 'Admin/layout';
  11.  
  12.     public function index(){
  13.         $data = array('title' => 'Admin', 'main_view' => 'Admin/home');
  14.         $this->load->view($this->layout, $data);
  15.     }
  16.    
  17.   public function tambahharga(){
  18.         $data = array('title' => 'Tambah Harga', 'main_view' => 'Admin/Harga/harga_baru');
  19.         $this->load->view($this->layout, $data);
  20.   }
  21.  
  22.   function datareklame(){
  23.        
  24.         $keyword_reklame = $this->uri->segment(3);
  25.        
  26.         $data = $this->db->query("SELECT * from tb_reklame where nama_reklame like '%$keyword_reklame%'");
  27.  
  28.         foreach($data->result() as $row){
  29.             $arr['query'] = $keyword_reklame%
  30.             $arr['suggestions'][] = array(
  31.                 'value' =>$row->nama_reklame,
  32.                 'id_reklame' =>$row->id_reklame,
  33.                 'keterangan' => $row->keterangan,
  34.                 'alamat' => $row->alamat
  35.             );
  36.         }
  37.         echo json_encode($arr);
  38.    
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment