Advertisement
Guest User

Untitled

a guest
Aug 7th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.48 KB | None | 0 0
  1. ini di model .....!!!  untuk ngambil data --> udah OK
  2.  
  3. <?php
  4.  
  5.  class Model_mahasiswa extends CI_Model {
  6.  
  7.  
  8.  Function getdata ()(
  9.  
  10.  
  11.  $url = "http://10.11.4.34/mahasiswa/index_get?nama="._GET["nama"];
  12.  
  13.          $ch = curl_init();
  14.  
  15.          curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
  16.      
  17.          curl_setopt($ch,CURLOPT_URL,$url);
  18.  
  19.          $result=curl_exec($ch);
  20.  
  21.          curl_close($ch);
  22.      
  23.          $key = var_dump(json_decode($result,true));
  24.      
  25.          return $key ;
  26.        
  27.    }
  28.  }
  29. ?>
  30.  
  31.  
  32. ini di controll -> buat pehubung model dan view .. Mohon koreksi?
  33.  
  34. <?php
  35.  
  36. defined('BASEPATH') OR exit('No direct script access allowed');
  37.  
  38. class Search extends CI_Controller {
  39.  
  40.   public function __construct()
  41.  
  42.       {
  43.           parent::__construct();
  44.           $this->load->model('model_mahasiswa');
  45.         }
  46.    
  47.    
  48.    
  49.     public function index() {
  50.        
  51.         $hasil['key'] = $this->model_mahasiswa->getdata();
  52.        
  53.                
  54.         $this->load->view('mahasiswa_view', $hasil);
  55.     }
  56. }
  57.  
  58. ?>
  59.  
  60.  
  61. ini view ---- mohon dibantu memperbaiki.. :)
  62.  
  63. <?php
  64. $js      = $this->config->item('js');
  65. $css     = $this->config->item('css');
  66. $img     = $this->config->item('img');
  67. $images  = $this->config->item('images');
  68. ?>
  69.  
  70. <!-- header -->
  71.  
  72. <?php include_once dirname(__FILE__).'/../layouts/header.php'; ?>    
  73.  
  74.     <div class="content">
  75.    
  76.         <!-- left -->
  77.         <?php include_once dirname(__FILE__).'/../layouts/left.php'; ?>        
  78.        
  79.         <div id="middle">
  80.        
  81.        
  82.        
  83.         <!-- ========== pencarian dukcapil-->
  84.                
  85.                 <br />
  86.                 <br />
  87.                 <form action  = "<?php echo base_url()?>search" method="get">
  88.                     <div style="float:left; width:70px;"><strong><font color="000000">DUKCAPIL</font></strong></div>
  89.                     <input type="text" style="width:300px"  placeholder="Masukan nomor nik" name="nik">
  90.                     <button type="submit" value="submit" >CARI</button>
  91.                    
  92.                 </form>
  93.             <div>
  94.             <table>
  95.                 <?php
  96.        
  97.                   echo $key;
  98.                        
  99.                   Foreach($key as $hasil => $value) {
  100.            
  101.                     $ret[$hasil] = trim($value);
  102.                    
  103.                     }
  104.                    
  105.                
  106.                 ?>
  107.                      
  108.                
  109.            
  110.             </table>
  111.             </div>
  112.            
  113.            
  114.  
  115.                
  116.         </div>
  117.      
  118.     </div>
  119.    
  120.     <!-- footer -->
  121.     <?php include_once dirname(__FILE__).'/../layouts/footer.php'; ?>        
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128. INI data yang ada diwebservice
  129.  
  130. {"STATUS_CODE":"00","STATUS_DESCRIPTION":"SUCSESS","STATUS_TYPE":"MSG","content":[{"NAMA_LGKP":"MAULA RIDWAN",
  131. "ALAMAT":"KAMPUNG ASEM", "status":"PELAJAR\/MAHASISWA"}]}
  132.  
  133.  
  134. ini data keluarannya, bukannya udh didecode ya
  135.  
  136. array(4) { ["STATUS_CODE"]=> string(2) "00"
  137.            ["STATUS_DESCRIPTION"]=> string(7) "SUCSESS"
  138.            ["STATUS_TYPE"]=> string(3) "MSG"
  139.            ["content"]=> array(1) {
  140.            
  141.                     [0]=> array(3) {
  142.                    
  143.                             ["NAMA_LGKP"]=> string(12) "MAULA RIDWAN"  
  144.                             ["ALAMAT"]=> string(12) "KAMPUNG ASEM"  
  145.                             ["Status"]=> string(17) "PELAJAR/MAHASISWA" } } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement