-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetPics.php
38 lines (35 loc) · 1.03 KB
/
getPics.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
<?php
require 'database.php';
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type, Content-Range, Content-Disposition, Content-Description');
$picsSoFar = (int)htmlentities($_POST['pageIndex']);
$stmt = $mysqli->prepare(
sprintf("select name, rating, fileName, timeCreated from pics order by timeCreated DESC LIMIT %s,1", $picsSoFar));
if(!$stmt){
printf("Query Prep Failed: %s\n", $mysqli->error);
echo json_encode(array(
'success' => False,
'message' => 'DB query fail'
));
exit;
}
$stmt->execute();
$stmt->bind_result($name, $rating, $fileName, $timeCreated);
$data = array();
while($stmt->fetch()) {
$element = array(
'name' => $name,
'rating' => $rating,
'fileName' => $fileName,
'timestamp' => $timeCreated
);
array_push($data, $element);
}
$stmt->close();
echo json_encode(array(
'success' => True,
'data' => $data
));
exit;
?>