-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
74 lines (61 loc) · 2.26 KB
/
index.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
include 'api.php';
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client();
$response = $client->request(
'GET',
$base_url
);
$body_json = $response->getBody();
$result = json_decode($body_json);
// foreach ($result as $row) {
// echo $row->name;
// }
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Guzzle Rest API Client CRUD</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2 style="text-align: center;">Guzzle Rest API Client CRUD</h2>
<br><br><br>
<a class="btn btn-primary" href="create.php" role="button">Create</a>
<br>
<table class="table">
<thead>
<tr>
<th style="text-align: center;">_id</th>
<th style="text-align: center;">Name</th>
<th style="text-align: center;">Age</th>
<th style="text-align: center;">Colour</th>
<th style="text-align: center;" colspan="2">Action</th>
</tr>
</thead>
<tbody>
<?php
foreach ($result as $row) { ?>
<tr>
<td style="text-align: center;"><?php echo $row->_id ?></td>
<td style="text-align: center;"><?php echo $row->name ?></td>
<td style="text-align: center;"><?php echo $row->age ?></td>
<td style="text-align: center;"><?php echo $row->colour ?></td>
<td style="text-align: center;"><a href='form-edit.php?id=<?php echo $row->_id ?>'>Edit</a></td>
<td style="text-align: center;"><a href='delete.php?id=<?php echo $row->_id ?>'>Delete</a></td>
</tr>
<?php
}
?>
</tbody>
</table>
<br><br>
</div>
</body>
</html>