[Solved] How to create pagination [closed]


You need more than try this for size::

$results_per_page = 10;
$current = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;

global $wpdb;

$table = $wpdb->prefix."car_saver";  
$rows = $wpdb->get_results("SELECT * FROM " . $table );


if( !empty($wp_query->query_vars['s']) ):
 $args['add_args'] = array('s'=>get_query_var('s'));
endif;

$args = array(
  'base' => @add_query_arg('paged','%#%'),
  'format' => '',
  'total' => ceil(sizeof($rows)/$results_per_page),
  'current' => $current,
  'show_all' => false,
  'type' => 'plain',
  );

  echo paginate_links($args);
  $start = ($current - 1) * $results_per_page;
  $end = $start + $results_per_page;
  $end = (sizeof($rows) < $end) ? sizeof($rows) : $end;
  echo '<br />';

 for($i=$start;$i < $end ;++$i ):
  $row = $rows[$i];
 endfor;

1

solved How to create pagination [closed]