How would I paginate to 5 results in each page this query? I am trying to paginate the results from the table, I saw some examples but those make use of db_select, I chose db_query. Is there a way to get the paging with db_query? I have been trying to translate the code into db_select but no luck, support please! Thanks!
Here is my code!

function rss_list_form($form, $form_state) {
  $header = array(
    'article' =&gt; t('Article'),
  );

  $sql = "SELECT * FROM {rss_table}";
  $result = db_query($sql);

  $rows = array();
  foreach ($result as $dbrow) {
    $rows[$dbrow-&gt;GUID] = array(
      'article' =&gt; '&lt;h3&gt;'.$dbrow-&gt;title . '&lt;/h3&gt;' . '&lt;br&gt;&lt;p&gt;' . strip_tags($dbrow-&gt;description, '&lt;p&gt;&lt;b&gt;&lt;a&gt;&lt;img&gt;&lt;br&gt;') . '&lt;p&gt;&lt;br&gt;' . '&lt;b&gt;' . $dbrow-&gt;date . '&lt;/b&gt;&lt;br&gt;&lt;em&gt;' . $dbrow-&gt;link . '&lt;/em&gt;&lt;br&gt;',
    );
  }

  $form['rss_select'] = array(
    '#type' =&gt; 'tableselect',
    '#header' =&gt; $header,
    '#options' =&gt; $rows,
    '#empty' =&gt; t('No articles found.'),
  );

  $form['import'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Import'),
    '#weight' =&gt; 0,
    '#submit'=&gt; array('rss_list_form_import'),
  );

  $form['update'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Update'),
    '#weight' =&gt; 1,
    '#submit'=&gt; array('rss_list_form_update'),
  );

  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Submit'),
    '#submit'=&gt; array('rss_list_form_submit'),
  );

  $form['delete'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Delete'),
    '#submit'=&gt; array('rss_list_form_delete'),
  );

  return $form;


}
The better way to use db_select with called as query extender.

Here is an example

$query = db_select('rss_table')
  -&gt;extend('PagerDefault')
  -&gt;limit(5);


Then theme_pager() can be used for outputting a pager.

For more detailed example check out

Either way to use pagination

 function pager_array_splice($data, $limit = 9, $element = 0) {

             global $pager_page_array, $pager_total, $pager_total_items;

                $page = isset($_GET['page']) ? $_GET['page'] : '';

  // Convert comma-separated $page to an array, used by other functions.
                $pager_page_array = explode(',', $page);

  // We calculate the total of pages as ceil(items / limit).
                $pager_total_items[$element] = count($data);
                $pager_total[$element] = ceil($pager_total_items[$element] / $limit);
                $pager_page_array[$element] = max(0, min((int)$pager_page_array[$element], ((int)$pager_total[$element]) - 1));
                return array_slice($data, $pager_page_array[$element] * $limit, $limit, TRUE);
}




 $query = db_select('rss_table','t');
            $query-&gt;fields('t');

           $resultget=$query-&gt;execute();

           $result = $resultget-&gt;fetchAll();
              $limit=5;
              $output = pager_array_splice($result, $limit); 
              $html='';

   foreach ($output as $dbrow) {

                    $items[]=(array)$dbrow;
                    $title = $dbrow-&gt;title;
                    $description = $dbrow-&gt;description;

$html.="         //HTML code here//       ";



 }


  $output1 = theme('item_list', array(
    'items' =&gt; $items));

    echo $html;


You can use it as in the form of table too or append it to the form as well. This is the way to use pagination.

Use this code to modify as per desired output.

Hope it works for you!