Howdy guys,
You have one'hell'of'a'fancy place out here!
Though I have a problem. I got a database full of MySQL - 4.1.22 that is being ordered around by phpMyAdmin - 2.8.1. The database has entries containing portfolio projects in three different fields categories.
For every category I want to define an order or sequence. I created a variable for this called "volgorde".
Now whenever I add a project into the db - using a form to do that -, into a certain category, THAT category (only) is updated by a +1 for every entry already there that has the same or higher "volgorde" (sequence/order) as the inserted entry. (Basically, all three categories can have their own 1 to N lists for sequence)
So far so good

that works!
Now when I MOVE an existing project that already has a "volgorde" up or down, the same trick has to happen, but when I move a project down, the projects that are "jumped over" do not go up.
The first query
should -1 all entries that have "volgorde" bigger than the entry that is being moved, AND smaller or equal to where the moved entry is going. Example: rank 1 moves to rank 3: rank 2 and 3 should move up: -1.
The second query
should +1 all entries that have "volgorde" smaller than the entry that is being moved, AND bigger or equal to where the moved entry is going. Example: rank 3 moves to rank 1: rank 1 and 2 should move down: +1.
CODE
$result=db_query(sprintf("UPDATE portfolio SET volgorde = volgorde -1 WHERE volgorde >= 'volgorde[$id]' AND volgorde <= '%s' AND type = '%s' ",$form['volgorde'], $form['afdeling']));
$result=db_query(sprintf("UPDATE portfolio SET volgorde = volgorde +1 WHERE volgorde < 'volgorde[$id]' AND volgorde >= '%s' AND type = '%s' ",$form['volgorde'], $form['afdeling']));
I immediately agree that I'm quite n00bish at mySQL. The really frustrating part is that I know that this should be possible, I know my syntax is good enough for you to understand, but it's just not good enough for that good'old databases.
Also, this is an addition to an already existing framework that deals very well with the projects and all kind of video and images. The only functionality I missed was a way to deal with an order/sequence to be filled into the edit form; AND WORK!