Forum Moderators: open
Basically we have a pagination system that works flawlessly (until now.)
$per_page = 25.
($order,$limit) = &getLimitString.
What this does is returns "order by [table.field] limit [start record number],$per_page".
Adjustments are made for zero-bas-ed-ness, for the sake of argument presume this works and has for years.
So we get a select something like this:
select table.id, table.company_id,table.cat_id from table $order $limit;
which is literally,
select table.id, table.company_id,table.cat_id from table order by table.date_created desc limit 0,25;
OK so far? There are 27 records. This means the first page displays the first 25, and our footlinks have links to next and page results numbers. On the second page, as you'd expect, there are two records.
There are no duplicates being output on either page. But the record that would be the last record on page 1 (or first on page 2, haven't chased it that far) is missing. It's not on either page, and we know it's in the DB.
My only possible explanation: by ordering by date_created desc, the first query pushes the missing record on page two. The second query, which looks something like this,
select table.id, table.company_id,table.cat_id from table order by table.date_created desc limit 25,25;
Dos not start with the missing record, it starts with the record that should be after it, as it should.
Remove the order by clause and everything's golden. it just outputs by record id, and we need to most recent entries toward the top of the first page.
What is bonehead missing here? :-)
select table.id, table.company_id,table.cat_id from table order by table.date_created desc limit 0,25;
while ((@row) = fetchrow_array) {
.. output rows
}
Then a subsequent page,
select table.id, table.company_id,table.cat_id from table order by table.date_created desc limit 25,25;
while ((@row) = fetchrow_array) {
.. output rows
}
Remove
order by table.date_created desc
And all is well. date_created is a date field, and present in all records.