fork download
  1. <?php
  2. include_once("db_connect.php");
  3. //employee
  4. $post = $total_employee = $employee_records = array();
  5. $total_employee_sql = $employee_sql = $where_condition = "";
  6. $post = $_REQUEST;
  7. $limit = $post["rowCount"];
  8. // handling pagination
  9. if (isset($post["current"])) {
  10. $page = $post["current"];
  11. } else {
  12. $page = 1;
  13. }
  14. $start = ($page-1) * $limit;
  15. // handling search
  16. if(!empty($post['searchPhrase'])) {
  17. $where_condition .=" WHERE ";
  18. $where_condition .=" ( url LIKE '".$post['searchPhrase']."%' ";
  19. $where_condition .=" OR title LIKE '".$post['searchPhrase']."%' ";
  20. $where_condition .=" OR description LIKE '".$post['searchPhrase']."%' )";
  21. }
  22. // handling sorting
  23. if( !empty($post['sort']) ) {
  24. $where_condition .=" ORDER By ".key($post['sort']) .' '.current($post['sort'])." ";
  25. }
  26. $sql_query = "SELECT id_news as emp_id, url as emp_name, title as emp_salary, description as emp_age FROM `news` ";
  27. $total_employee_sql .= $sql_query;
  28. $employee_sql .= $sql_query;
  29. if(isset($where_condition) && $where_condition != '') {
  30. $total_employee_sql .= $where_condition;
  31. $employee_sql .= $where_condition;
  32. }
  33. // handling limit to get data
  34. if ($limit!=-1) {
  35. $employee_sql .= "LIMIT $start, $limit";
  36. }
  37. // Getting total number of employee record count
  38. $result_total = mysqli_query($conn, $total_employee_sql) or die("database error:". mysqli_error($conn));
  39. $total_employee = mysqli_num_rows($result_total);
  40. // getting eployee records and store into an array
  41. $resultset = mysqli_query($conn, $employee_sql) or die("database error:". mysqli_error($conn));
  42. while( $employee = mysqli_fetch_assoc($resultset) ) {
  43. $employee_records[] = $employee;
  44. }
  45. // creating employee data array according to jQuery Bootgrid requirement to display records
  46. $employee_json_data = array(
  47. "current" => intval($post['current']),
  48. 'rowCount' => 10,
  49. "total" => intval($total_employee),
  50. "rows" => $employee_records
  51. );
  52. // return employee data array as JSON data
  53. echo json_encode($employee_json_data);
  54. ?>
Runtime error #stdin #stdout #stderr 0.02s 82560KB
stdin
Standard input is empty
stdout
   
stderr
PHP Warning:  include_once(db_connect.php): failed to open stream: No such file or directory in /home/vvz8xS/prog.php on line 2
PHP Warning:  include_once(): Failed opening 'db_connect.php' for inclusion (include_path='.:/usr/share/php') in /home/vvz8xS/prog.php on line 2
PHP Notice:  Undefined index: rowCount in /home/vvz8xS/prog.php on line 7
PHP Fatal error:  Uncaught Error: Call to undefined function mysqli_query() in /home/vvz8xS/prog.php:38
Stack trace:
#0 {main}
  thrown in /home/vvz8xS/prog.php on line 38