Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
- <!-- jQuery -->
- <title>Lista de noticias</title>
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-bootgrid/1.3.1/jquery.bootgrid.css" />
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-bootgrid/1.3.1/jquery.bootgrid.js"></script>
- <script src="ajax.js"></script>
- </head>
- <body class="">
- <div role="navigation" class="navbar navbar-default navbar-static-top">
- <div class="container">
- <div class="navbar-header">
- <button data-target=".navbar-collapse" data-toggle="collapse" class="navbar-toggle" type="button">
- <span class="sr-only">Toggle navigation</span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </button>
- <a href="#" class="navbar-brand">My Site</a>
- </div>
- <div class="navbar-collapse collapse">
- <ul class="nav navbar-nav">
- <li class="active"><a href="index.php">Home</a></li>
- </ul>
- </div><!--/.nav-collapse -->
- </div>
- </div>
- <div class="container" style="min-height:500px;">
- <div class=''></div>
- <div class="container">
- <h2>Listado de Noticias</h2>
- <br>
- <br>
- <table id="news" data-toggle="bootgrid" class="table table-condensed table-hover table-striped" width="100%" cellspacing="0">
- <thead>
- <tr>
- <th data-column-id="emp_id" data-type="numeric">Id</th>
- <th data-column-id="emp_name">Titulo</th>
- <th data-column-id="emp_salary">Descripción</th>
- <th data-column-id="emp_age">URL</th>
- </tr>
- </thead>
- </table>
- <div class="insert-post-ads1" style="margin-top:20px;">
- </div>
- </div>
- </body>
- </html>
- $sql_query = "SELECT id_news as emp_id, url as emp_name, title as emp_salary, description as emp_age FROM `news` ";
- <?php
- include_once("db_connect.php");
- //employee
- $post = $total_employee = $employee_records = array();
- $total_employee_sql = $employee_sql = $where_condition = "";
- $post = $_REQUEST;
- $limit = $post["rowCount"];
- // handling pagination
- if (isset($post["current"])) {
- $page = $post["current"];
- } else {
- $page = 1;
- }
- $start = ($page-1) * $limit;
- // handling search
- if(!empty($post['searchPhrase'])) {
- $where_condition .=" WHERE ";
- $where_condition .=" ( url LIKE '".$post['searchPhrase']."%' ";
- $where_condition .=" OR mini_title LIKE '".$post['searchPhrase']."%' ";
- $where_condition .=" OR mini_description LIKE '".$post['searchPhrase']."%' )";
- }
- // handling sorting
- if( !empty($post['sort']) ) {
- $where_condition .=" ORDER By ".key($post['sort']) .' '.current($post['sort'])." ";
- }
- $sql_query = "SELECT id_news as emp_id, url as emp_name, title as emp_salary, description as emp_age FROM `news` ";
- $total_employee_sql .= $sql_query;
- $employee_sql .= $sql_query;
- if(isset($where_condition) && $where_condition != '') {
- $total_employee_sql .= $where_condition;
- $employee_sql .= $where_condition;
- }
- // handling limit to get data
- if ($limit!=-1) {
- $employee_sql .= "LIMIT $start, $limit";
- }
- // Getting total number of employee record count
- $result_total = mysqli_query($conn, $total_employee_sql) or die("database error:". mysqli_error($conn));
- $total_employee = mysqli_num_rows($result_total);
- // getting eployee records and store into an array
- $resultset = mysqli_query($conn, $employee_sql) or die("database error:". mysqli_error($conn));
- while( $employee = mysqli_fetch_assoc($resultset) ) {
- $employee_records[] = $employee;
- }
- // creating employee data array according to jQuery Bootgrid requirement to display records
- $employee_json_data = array(
- "current" => intval($post['current']),
- 'rowCount' => 10,
- "total" => intval($total_employee),
- "rows" => $employee_records
- );
- // return employee data array as JSON data
- echo json_encode($employee_json_data);
- ?>
- id_news url title description
- 1 .... un titulo ........
Add Comment
Please, Sign In to add comment