-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.php
More file actions
36 lines (28 loc) · 808 Bytes
/
server.php
File metadata and controls
36 lines (28 loc) · 808 Bytes
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
<?php
include_once "./config.php";
$request = $_GET;
if(isset($request["pageSize"])) {
$pageSize = $request["pageSize"];
} else {
$pageSize = 4;
}
$connection = mysql_connect('localhost', DATABASE_USER, DATABASE_PASSWORD);
mysql_select_db('carousel', $connection);
$result = array();
$totalSql = 'select count(*) cnt from Item';
$idf = mysql_query($totalSql, $connection);
$total = mysql_fetch_assoc($idf);
$startOffset = $request['page'] * $pageSize;
$sql = 'select * from Item limit ' . $startOffset . ',' . $pageSize;
$idf = mysql_query($sql, $connection);
$i = 0;
while($row = mysql_fetch_assoc($idf)){
$result[] = $row;
}
echo json_encode(array(
'items' => $result,
'pageSize' => $pageSize,
'pageNum' => $request['page'],
'total' => $total['cnt']
));
?>