Can someone please show me some examples or show me how, I already got the parms working but I dont know how i would do the api what im trying to do is make it get the data from my database with the currentpage and pagesize/limit I have got limit to work but I cant figure out how I would do current page
this is what ive got so far
<?php
require ($_SERVER['DOCUMENT_ROOT']."/core/config.php");
require ($_SERVER['DOCUMENT_ROOT']."/core/session.php");
if ($logged == false) {
header('Location: /');
exit;
}
$limit = mysqli_real_escape_string($conn, $_GET['pageSize']);
if(intval($limit)) {
$sqlSearch = "SELECT * FROM `users` ORDER BY `id` DESC LIMIT $limit";
$result = $conn->query($sqlSearch);
while ($userrows = $result->fetch_assoc()) {
$username = $userrows['username'];
$apiresp = array('success' => "true", 'username' => $username);
echo json_encode($apiresp);
}
}
?>
sorry if i explained this bad im kind of in a rush and have been trying for hours :(
CodePudding user response:
You probably want to use offset
SELECT * FROM `users` ORDER BY `id` DESC LIMIT $limit,". ($page -1)*$limit;