Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ini di model .....!!! untuk ngambil data --> udah OK
- <?php
- class Model_mahasiswa extends CI_Model {
- Function getdata ()(
- $url = "http://10.11.4.34/mahasiswa/index_get?nama="._GET["nama"];
- $ch = curl_init();
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
- curl_setopt($ch,CURLOPT_URL,$url);
- $result=curl_exec($ch);
- curl_close($ch);
- $key = var_dump(json_decode($result,true));
- return $key ;
- }
- }
- ?>
- ini di controll -> buat pehubung model dan view .. Mohon koreksi?
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class Search extends CI_Controller {
- public function __construct()
- {
- parent::__construct();
- $this->load->model('model_mahasiswa');
- }
- public function index() {
- $hasil['key'] = $this->model_mahasiswa->getdata();
- $this->load->view('mahasiswa_view', $hasil);
- }
- }
- ?>
- ini view ---- mohon dibantu memperbaiki.. :)
- <?php
- $js = $this->config->item('js');
- $css = $this->config->item('css');
- $img = $this->config->item('img');
- $images = $this->config->item('images');
- ?>
- <!-- header -->
- <?php include_once dirname(__FILE__).'/../layouts/header.php'; ?>
- <div class="content">
- <!-- left -->
- <?php include_once dirname(__FILE__).'/../layouts/left.php'; ?>
- <div id="middle">
- <!-- ========== pencarian dukcapil-->
- <br />
- <br />
- <form action = "<?php echo base_url()?>search" method="get">
- <div style="float:left; width:70px;"><strong><font color="000000">DUKCAPIL</font></strong></div>
- <input type="text" style="width:300px" placeholder="Masukan nomor nik" name="nik">
- <button type="submit" value="submit" >CARI</button>
- </form>
- <div>
- <table>
- <?php
- echo $key;
- Foreach($key as $hasil => $value) {
- $ret[$hasil] = trim($value);
- }
- ?>
- </table>
- </div>
- </div>
- </div>
- <!-- footer -->
- <?php include_once dirname(__FILE__).'/../layouts/footer.php'; ?>
- INI data yang ada diwebservice
- {"STATUS_CODE":"00","STATUS_DESCRIPTION":"SUCSESS","STATUS_TYPE":"MSG","content":[{"NAMA_LGKP":"MAULA RIDWAN",
- "ALAMAT":"KAMPUNG ASEM", "status":"PELAJAR\/MAHASISWA"}]}
- ini data keluarannya, bukannya udh didecode ya
- array(4) { ["STATUS_CODE"]=> string(2) "00"
- ["STATUS_DESCRIPTION"]=> string(7) "SUCSESS"
- ["STATUS_TYPE"]=> string(3) "MSG"
- ["content"]=> array(1) {
- [0]=> array(3) {
- ["NAMA_LGKP"]=> string(12) "MAULA RIDWAN"
- ["ALAMAT"]=> string(12) "KAMPUNG ASEM"
- ["Status"]=> string(17) "PELAJAR/MAHASISWA" } } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement