You are here: Re: [PHP] Sort table by column and pagination « PHP « IT news, forums, messages
Re: [PHP] Sort table by column and pagination

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация