Skip to main content

Posts

Showing posts with the label pagination

Pagination with MySql, jQuery & Php

Ajax pagination with MySQL, PHP and jQuery Method 1: Javascript : <script type="text/javascript"> $(document).ready(function(){ function loading_show(){ $('#loading').html("<img src='images/loading.gif'/>").fadeIn('fast'); } function loading_hide(){ $('#loading').fadeOut('fast'); }                 function loadData(page){ loading_show();                     $.ajax ({ type: "POST", url: "load_data.php", data: "page="+page, success: function(msg) { $("#container").ajaxComplete(function(event, request, settings) { loading_hide(); $("#container").html(msg); }); } }); } loadData(1);  $('#container .pagination li.active').on('click',function(){ var page = $(this).attr('p'); loadData(page); }); }); </script> ...

CakePHP pagination

Paginate provide a set of controls to navigate through paged data. Pagination inside Controller class RecipesController extends AppController {     public $components = array('Paginator');     public $paginate = array(         'limit' => 25,         'contain' => array('Article')     ); } Pagination define inside function public function list_recipes() {     $this->Paginator->settings = $this->paginate;     // similar to findAll(), but fetches paged results     $data = $this->Paginator->paginate('Recipe');     $this->set('data', $data); } You can filter the records by passing conditions as second parameter to the paginate() function: $data = $this->Paginator->paginate(     'Recipe',     array('Recipe.title LIKE' => 'a%') ); Pagination with behaviour  $this->paginate=array('conditions'=...