title: How to implement pagination in joomla?
body: <p>I am implementing pagination in joomla.The following is the code</p>
  
  <pre><code>      $db = JFactory::getDbo();
        $query = $db-&gt;getQuery(true)
                          -&gt;select('c.*,cat.alias as catalias')
                          -&gt;from('#__content AS c')
                          -&gt;from('#__categories AS cat')
                          -&gt;where('c.catid=19','AND')
                          -&gt;where('c.state=1','AND')
                          -&gt;where('c.catid = cat.id')
                          -&gt;order('c.created '.' ASC');
  
      $db-&gt;setQuery($query,0,5);
      $results = $db-&gt;loadAssocList();
      $db-&gt;setQuery('SELECT FOUND_ROWS();');
      jimport('joomla.html.pagination');
      $pager= new JPagination($db-&gt;loadResult(), 0, 2);
  
      foreach ($results as $res) {  
      echo $res['id'];
      ....
      .....
      }
  
      echo $pager-&gt;getListFooter();
  </code></pre>
  
  <p>This shows page numbers at footer(like 1 2 3 with hyper links) based on page limit(6 records in 3 pages(page limit 2)).But all the records displayed in single page.Not like two records in each page.</p>
  
  <p>what changes need here.Please help me anyone.</p>
  
  <p>Thanks in advance </p>