Re: How Best to Maintain Sort Order Field

From: Date: Fri, 20 Apr 2007 14:55:31 +0000
Subject: Re: How Best to Maintain Sort Order Field
References: 1 2 3 4 5 6 7  Groups: php.general 
Request: Send a blank email to php-general+get-253342@lists.php.net to get a copy of this message
2007. 04. 20, péntek keltezéssel 10.47-kor Stephen ezt írta: > Zoltán Németh wrote: > > nothing special. just like this: > > <button name="moveup" onclick="handler.php?cmd=moveup&id=1"> > > > > and then in handler.php do a switch for cmd and update the rows > > accordingly, then redirect back to the form > > > > > Thanks! > > Can you give me idea what the SQL should look like? please include the list in replies! btw, it cannot be solved with a single SQL query AFAIK. for example, move up requires the following steps: 1. get the order value of the record to be moved (simple select) 2. get the record which has one less order value (the record above) (another select) 3. update the records with the new order values (2 separate updates) similarly you should be able to define the logic for movement down and so on... greets Zoltán Németh > > Stephen

« previous php.general (#253342) next »