View difference between Paste ID: Akk1YybE and tek2jQqe
SHOW: | | - or go back to the newest paste.
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));
23+
          //$key = var_dump(json_decode($result,true));
24
/*
25
fyi.. var_dump itu echo aka ngeluarin hasil.. bukan balikin berupa nilai parameter
26
{
27
28
    "STATUS_CODE":"00",
29
    "STATUS_DESCRIPTION":"SUCSESS",
30
    "STATUS_TYPE":"MSG",
31
    "content":[
32
        {
33
            "NAMA_LGKP":"MAULA RIDWAN",
34
            "ALAMAT":"KAMPUNG ASEM",
35
            "status":"PELAJAR\/MAHASISWA"
36
        }
37
    ]
38
39
}
40
*/
41
42
$raw = json_decode($result,true);
43
$key=array(
44
'nama'=>isset($raw['content']['NAMA_LGKP'])?$raw['content']['NAMA_LGKP']:'',
45
'alamat'=>isset($raw['content']['ALAMAT'])?$raw['content']['ALAMAT']:'',
46
'status'=>isset($raw['content']['status'])?$raw['content']['status']:''
47
48
);
49
/**
50
gunakan key nya nama, alamat, status
51
**/
52
          return $key ;
53
         
54
    }
55
  }
56
?>
57
 
58
 
59
ini di controll -> buat pehubung model dan view .. Mohon koreksi?
60
 
61
<?php
62
 
63
defined('BASEPATH') OR exit('No direct script access allowed');
64
 
65
class Search extends CI_Controller {
66
 
67
   public function __construct()
68
 
69
       {
70
           parent::__construct();
71
           $this->load->model('model_mahasiswa');
72
        }
73
   
74
   
75
   
76
    public function index() {
77
       
78
        $hasil['key'] = $this->model_mahasiswa->getdata();
79
       
80
               
81
        $this->load->view('mahasiswa_view', $hasil);
82
    }
83
}
84
 
85
?>
86
 
87
 
88
ini view ---- mohon dibantu memperbaiki.. :)
89
 
90
<?php
91
$js      = $this->config->item('js');
92
$css     = $this->config->item('css');
93
$img     = $this->config->item('img');
94
$images  = $this->config->item('images');
95
?>
96
 
97
<!-- header -->
98
 
99
<?php include_once dirname(__FILE__).'/../layouts/header.php'; ?>    
100
 
101
    <div class="content">
102
   
103
        <!-- left -->
104
        <?php include_once dirname(__FILE__).'/../layouts/left.php'; ?>        
105
       
106
        <div id="middle">
107
       
108
       
109
       
110
        <!-- ========== pencarian dukcapil-->
111
               
112
                <br />
113
                <br />
114
                <form action  = "<?php echo base_url()?>search" method="get">
115
                    <div style="float:left; width:70px;"><strong><font color="000000">DUKCAPIL</font></strong></div>
116
                    <input type="text" style="width:300px"  placeholder="Masukan nomor nik" name="nik">
117
                    <button type="submit" value="submit" >CARI</button>
118
                   
119
                </form>
120
            <div>
121
            <table>
122
                <?php
123
         
124
                   echo $key;
125
                         
126
                   Foreach($key as $hasil => $value) {
127
           
128
                    $ret[$hasil] = trim($value);
129
                   
130
                    }
131
                   
132
               
133
                ?>
134
                     
135
               
136
           
137
            </table>
138
            </div>
139
           
140
           
141
 
142
               
143
        </div>
144
     
145-
                            ["Status"]=> string(17) "PELAJAR/MAHASISWA" } } }
145+
146
   
147
    <!-- footer -->
148
    <?php include_once dirname(__FILE__).'/../layouts/footer.php'; ?>        
149
 
150
 
151
 
152
 
153
 <!--
154
 
155
INI data yang ada diwebservice
156
 
157
{"STATUS_CODE":"00","STATUS_DESCRIPTION":"SUCSESS","STATUS_TYPE":"MSG","content":[{"NAMA_LGKP":"MAULA RIDWAN",
158
"ALAMAT":"KAMPUNG ASEM", "status":"PELAJAR\/MAHASISWA"}]}
159
 
160
 
161
ini data keluarannya, bukannya udh didecode ya
162
 
163
array(4) { ["STATUS_CODE"]=> string(2) "00"
164
           ["STATUS_DESCRIPTION"]=> string(7) "SUCSESS"
165
           ["STATUS_TYPE"]=> string(3) "MSG"
166
           ["content"]=> array(1) {
167
           
168
                    [0]=> array(3) {
169
                   
170
                            ["NAMA_LGKP"]=> string(12) "MAULA RIDWAN"  
171
                            ["ALAMAT"]=> string(12) "KAMPUNG ASEM"  
172
                            ["Status"]=> string(17) "PELAJAR/MAHASISWA" } } }
173
174
-->