Guest User

Untitled

a guest
Sep 23rd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.45 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  6. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
  7. <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
  8. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
  9. <!-- jQuery -->
  10. <title>Lista de noticias</title>
  11. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-bootgrid/1.3.1/jquery.bootgrid.css" />
  12. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-bootgrid/1.3.1/jquery.bootgrid.js"></script>
  13. <script src="ajax.js"></script>
  14. </head>
  15. <body class="">
  16. <div role="navigation" class="navbar navbar-default navbar-static-top">
  17. <div class="container">
  18. <div class="navbar-header">
  19. <button data-target=".navbar-collapse" data-toggle="collapse" class="navbar-toggle" type="button">
  20. <span class="sr-only">Toggle navigation</span>
  21. <span class="icon-bar"></span>
  22. <span class="icon-bar"></span>
  23. <span class="icon-bar"></span>
  24. </button>
  25. <a href="#" class="navbar-brand">My Site</a>
  26. </div>
  27. <div class="navbar-collapse collapse">
  28. <ul class="nav navbar-nav">
  29. <li class="active"><a href="index.php">Home</a></li>
  30. </ul>
  31.  
  32. </div><!--/.nav-collapse -->
  33. </div>
  34. </div>
  35.  
  36. <div class="container" style="min-height:500px;">
  37. <div class=''></div>
  38. <div class="container">
  39. <h2>Listado de Noticias</h2>
  40. <br>
  41. <br>
  42. <table id="news" data-toggle="bootgrid" class="table table-condensed table-hover table-striped" width="100%" cellspacing="0">
  43. <thead>
  44. <tr>
  45. <th data-column-id="emp_id" data-type="numeric">Id</th>
  46. <th data-column-id="emp_name">Titulo</th>
  47. <th data-column-id="emp_salary">Descripción</th>
  48. <th data-column-id="emp_age">URL</th>
  49. </tr>
  50. </thead>
  51. </table>
  52. <div class="insert-post-ads1" style="margin-top:20px;">
  53.  
  54. </div>
  55. </div>
  56. </body>
  57. </html>
  58.  
  59. $sql_query = "SELECT id_news as emp_id, url as emp_name, title as emp_salary, description as emp_age FROM `news` ";
  60.  
  61. <?php
  62. include_once("db_connect.php");
  63. //employee
  64. $post = $total_employee = $employee_records = array();
  65. $total_employee_sql = $employee_sql = $where_condition = "";
  66. $post = $_REQUEST;
  67. $limit = $post["rowCount"];
  68. // handling pagination
  69. if (isset($post["current"])) {
  70. $page = $post["current"];
  71. } else {
  72. $page = 1;
  73. }
  74. $start = ($page-1) * $limit;
  75. // handling search
  76. if(!empty($post['searchPhrase'])) {
  77. $where_condition .=" WHERE ";
  78. $where_condition .=" ( url LIKE '".$post['searchPhrase']."%' ";
  79. $where_condition .=" OR mini_title LIKE '".$post['searchPhrase']."%' ";
  80. $where_condition .=" OR mini_description LIKE '".$post['searchPhrase']."%' )";
  81. }
  82. // handling sorting
  83. if( !empty($post['sort']) ) {
  84. $where_condition .=" ORDER By ".key($post['sort']) .' '.current($post['sort'])." ";
  85. }
  86. $sql_query = "SELECT id_news as emp_id, url as emp_name, title as emp_salary, description as emp_age FROM `news` ";
  87. $total_employee_sql .= $sql_query;
  88. $employee_sql .= $sql_query;
  89. if(isset($where_condition) && $where_condition != '') {
  90. $total_employee_sql .= $where_condition;
  91. $employee_sql .= $where_condition;
  92. }
  93. // handling limit to get data
  94. if ($limit!=-1) {
  95. $employee_sql .= "LIMIT $start, $limit";
  96. }
  97. // Getting total number of employee record count
  98. $result_total = mysqli_query($conn, $total_employee_sql) or die("database error:". mysqli_error($conn));
  99. $total_employee = mysqli_num_rows($result_total);
  100. // getting eployee records and store into an array
  101. $resultset = mysqli_query($conn, $employee_sql) or die("database error:". mysqli_error($conn));
  102. while( $employee = mysqli_fetch_assoc($resultset) ) {
  103. $employee_records[] = $employee;
  104. }
  105. // creating employee data array according to jQuery Bootgrid requirement to display records
  106. $employee_json_data = array(
  107. "current" => intval($post['current']),
  108. 'rowCount' => 10,
  109. "total" => intval($total_employee),
  110. "rows" => $employee_records
  111. );
  112. // return employee data array as JSON data
  113. echo json_encode($employee_json_data);
  114. ?>
  115.  
  116. id_news url title description
  117. 1 .... un titulo ........
Add Comment
Please, Sign In to add comment