You are here: Re: More CMS help « PHP Programming Language « IT news, forums, messages
Re: More CMS help

Posted by Adam Plocher on 01/20/06 18:51

This is how I normally achieve a sortable list:

You should start by setting up a SortOrder (int) column. Each new
record that get's added should cause that # to increment. If this is
going to be a multi-user system or something you should increment it
based on that UserID (so there aren't gaps in the number). Then when
you want to move up simply do:

function MoveUp($id,$replaceID)
{
UPDATE table SET SortOrder=(SortOrder-1) WHERE ID=$id
UPDATE table SET SortOrder=(SortOrder+1) WHERE ID=$replaceID
}

move down would be similar

function MoveDown($id,$replaceID)
{
UPDATE table SET SortOrder=(SortOrder+1) WHERE ID=$id
UPDATE table SET SortOrder=(SortOrder-1) WHERE ID=$replaceID
}

And of course on your select you would ORDER BY SortOrder. There are
several ways you can accomplish this task, this is just the way I do
it. I don't know if this is necessarily the best way, but as long as
your script doesn't leave gaps in the SortOrder # you'll be fine.

 

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

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