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 19:45

Does this fix the problem? It will attempt to find the "replaceID"
automatically. You shouldn't need to shift every item, just the item
before or after the item you want to move.

function MoveUp($id)
{
$query = "SELECT ID FROM table WHERE SortOrder=(SortOrder+1)";
$ret = mysql_query($query);
if (mysql_num_rows($ret) == 1)
{
// if 0 rows returned, don't change the sortorder
list($replaceID) = mysql_fetch_row($ret);

$query = "UPDATE table SET SortOrder=(SortOrder-1) WHERE ID=$id"
mysql_query($query);

$query = "UPDATE table SET SortOrder=(SortOrder+1) WHERE ID=$replaceID"
mysql_query($query);
}
}

 

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

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