Advertisement
gundambison

grid_data.php

May 19th, 2018
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.   $callback jQuery1123009962440195479316_1526746247448
  5.   $format   json
  6.   $inlinecount  allpages
  7.   $skip 20
  8.   $top  20
  9.  */
  10. $mysqli = @new mysqli('localhost', 'root3', '', 'fb_demo');
  11.  
  12. // Works as of PHP 5.2.9 and 5.3.0.
  13. if ($mysqli->connect_error) {
  14.     die('Connect Error: ' . $mysqli->connect_error);
  15. }
  16.  
  17. $limit = isset($_GET['$top']) ? $_GET['$top'] : 10;
  18.  
  19. $start = isset($_GET['$skip']) ? $_GET['$skip'] : 0;
  20. $callback = $_GET['$callback'];
  21.  
  22.  
  23. $data = array();
  24.  
  25. $sql = "select * from my_orders limit $start,$limit";
  26. $que = $mysqli->query($sql);
  27. if ($que) {
  28.     while ($row = $que->fetch_array(MYSQLI_ASSOC)) {
  29.         $data[] = $row;
  30.     }
  31. } else {
  32.     die($mysqli->error);
  33. }
  34.  
  35.  
  36. $sql = "select count(*) c from my_orders  ";
  37. $que = $mysqli->query($sql);
  38. if ($que) {
  39.     $row = $que->fetch_array(MYSQLI_ASSOC);
  40.     $total = $row['c'];
  41. } else {
  42.     die($mysqli->error);
  43. }
  44. $result = array(
  45.     'results' => $data,
  46.     '__count' => $total
  47. );
  48. $respon = array('d' => $result, 'params' => $_GET);
  49.  
  50.  
  51. $json = json_encode($respon);
  52.  
  53. echo "$callback(\n$json\n)";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement