|
Posted by Philip Hallstrom on 08/26/05 23:19
> We have quite a complex product all written in PHP and our own mySQL
> wrapper. We initially wanted to use smarty, but due to time constraints, we
> couldn't re-write everything, so it never got implemented.
>
> Two feature requests we get a lot are the ability to sort the tabular data
> by column heading (click once for ascending and again for descending) and
> the second is pagination.
My guess is finding code that does this that you can integrate is going to
take longer than just doing it yourself. It's not that bad...
Just add some variables that either get kept in a session or passed around
via URL's to store the $offset and $order_by.
Then in your code set your $limit.
Then it's just a matter of adjusting your SQL to add "ORDER BY
$order_by LIMIT $limit OFFSET $offset" when relevant. For your array,
it's the same thing, but use array_slice.
To go to the next page just have the link set $offset to $offset + $limit.
Similarly for previous.
Then add the boundary checks, etc.
Good luck!
Navigation:
[Reply to this message]
|