-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget.php
40 lines (29 loc) · 964 Bytes
/
get.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
<?php
include 'koneksi.php';
$response['data'] = array();
$actual_link = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$halaman =isset($_GET["size"]) ? (int)$_GET["size"] : 25;
$page =isset($_GET["page"]) ? (int)$_GET["page"] : 1;
$mulai =($page>1) ? ($page * $halaman) - $halaman : 0;
$sql = "SELECT * FROM video";
$result = $conn->query($sql);
$total = mysqli_num_rows($result);
$pages = ceil($total/$halaman);
$tampilMas =$conn->query("SELECT * FROM video LIMIT $mulai, $halaman");
$no =$mulai+1;
$response['pages'] = $pages;
$response['total'] = $total;
if ($page!==$pages) {
$response['next'] = $actual_link.'?page='.($page+1);
}
if ($page!==1) {
$response['prev'] = $actual_link.'?page='.($page-1);
}
$response['current'] = $actual_link.'?page='.$page;
while($row = $tampilMas->fetch_assoc()) {
array_push($response["data"],$row['videoid']);
}
// // var_dump($total);
echo json_encode($response);
$conn->close();
?>