Resequencing logic
| From: | Matt Grimm | Date: | Fri, 07 May 2004 16:31:30 +0000 |
| Subject: | Resequencing logic | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-185646@lists.php.net to get a copy of this message | ||
I apologize if this message is a repeat; I've had trouble posting with
Thunderbird.
I'm interested in how you folks would approach the following issue:
You have a list of data, in a user-defined sequence. For instance, a list
of song titles that can be rearranged on a web page in any order. I don't
think I have the best grasp of the logic involved, and as such, the problem
is a real pain for me. I use this approach:
-If adding, records after or equal to the new (requested) spot are
incremented
-If moving up, records before the current spot and after or equal to the
new spot are incremented
-If moving down, records after the current spot and before or equal to the
new spot are decremented
-If deleting, records after or equal to the current spot are decremented
Is there some MySQL or PHP function that will handle this sort of
reordering business, or is there possibly a simpler logic I could use?
Thanks,
Matt
mgrimm@healthtvchannel.org