[Pugged] Moving up and down

ciapug@ciapug.org ciapug@ciapug.org
Wed, 11 Sep 2002 17:29:14 -0000


Lathrop Preston <laith@prestonfam.org> said:

> At 11:43 AM 9/11/2002, you wrote:
> >Another question!
> >
> >Again related to my forums. In my forum administration pages I have one 
> >where I can add, edit, delete, and re-order my categories and forums. I 
> >would like to ask if anyone has any good suggestions on how to handle the 
> >positioning, and the re-ordering.
> >
> ...

> I have seen both ways. I find the "catOrder" with up and down arrows to 
> swap items works fairly well. (the other runs a greater risk of user error)
> 
> While it does add a few more clicks if you are making a large change, I 
> wonder how often this feature would really be used. So the interface 
> overhead is probably not as much of a problem as the user error risk of the 
> other option.
> 

I agree... the clickey-arrow-thingy interface might be a tad bit slow if you're moving something from #25 to #1, but it introduces the smallest margin for error.

If you want to manually re-sequence, you can always do it in phpMyAdmin.

I've done something like this to resequence #'s... say I want to move record #5 up to sequence number 2. It would go something like:

save the id to $move_id & old seq # of record 5 to $old_seq.
set the seq of record 5 to 0
reduce the seq # of any record > 5:

UPDATE mycat SET seq_no = seq_no - 1 WHERE seq_no > $old_seq

now move the record to #2.

UPDATE mycat SET seq_no = 2 WHERE id = $move_id

now re-sequence the records:

UPDATE mycat SET seq_no = seq_no + 1 WHERE seq_no > 2

That's a bit rough, but you should be able to figure it out from there...

BTW - don't call your sequence # field "sequence". That's a "Bad Thing(tm)", being as how "sequence" is a reserved SQL keyword. Been there, been bit in the ass by that.

-dc