I’m am trying to paginate a set of results from a database query using $wbdb class. I’ve got it to paginate but I”m getting some freaky results and I’m not sure if this is normal. The code is printing a “>” at the top of the table for each result the query returns. Can anyone tell me what I’m doing wrong.
I’m using the following code that I got from
$rows_per_page = 10;
$current = (intval(get_query_var('paged'))) ? intval(get_query_var('paged')) : 1;
$rows = $wpdb->get_results('SELECT * FROM subscriber ORDER BY sub_lname ASC');
$start = ($current - 1) * $rows_per_page;
$end = $start + $rows_per_page;
$end = (sizeof($rows) < $end) ? sizeof($rows) : $end;
$pagination_args = array(
'base' => @add_query_arg('paged','%#%'),
'format' => '?page=%#%',
'total' => ceil(sizeof($rows)/$rows_per_page),
'current' => $current,
'show_all' => False,
'prev_next' => True,
'prev_text' => __('« Previous'),
'next_text' => __('Next »'),
'type' => 'plain',
'add_args' => False
);
echo paginate_links($pagination_args);
You can view the output live here http://www.thewaymultimedia.com/IML/manage-subscribers/page/2
The error is in the table’s printing code. The Phone Number
<td>tags are not appropriately closed.For example:
The last tag should be
</td>. This error is repeated in each row.You have to look for the function that prints the result and correct this.
By the way, the total number of rows is also wrong = total+1.