-
Notifications
You must be signed in to change notification settings - Fork 0
/
readrest.php
32 lines (27 loc) · 986 Bytes
/
readrest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
$endpoint = 'http://localhost/kuliah/rest/putrest.php';
$session = curl_init($endpoint);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($session);
curl_close($session);
$search_results = json_decode($data, true);
if ($search_results === NULL) die('Error parsing json');
echo '<table>';
foreach ($search_results['data'] as $mahasiswa) {
$nama = $mahasiswa["nama"];
$nim = $mahasiswa["nim"];
$umur = $mahasiswa["prodi"];
$gambar = $mahasiswa["ipk"];
$id = $mahasiswa["idmahasiswa"];
echo '<tr>
<td>' . $nama . '</td>
<td>' . $nim . '</td>
<td>' . $umur . '</td>
<td>' . $gambar . '</td>
<td>
<a href="http://localhost/kuliah/rest/edit.php?idmahasiswa='.$id.'">Edit</a>
<a href="http://localhost/kuliah/rest/hapus.php?idmahasiswa='.$id.'">Hapus</a>
</td>
</tr>';
}
echo '</table>';