SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Custom Order

  1. #1
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Custom Order

    Hey everyone. I have been trying to wrap my head around a problem, but have yet to come up with any sort of solution...

    Basically what im trying to do is give the user the ability to sort records.. lets say photos for this example. So they will have a list of photos, and they can click on little down/up buttons and then the picture will move either one up, or one down in the list. And this order is saved in db by some numerical representation that can later called and displayed in the same order.


    so like if you have..

    photo 1 (move up) (move down)
    photo 2 (move up) (move down)
    photo 3 (move up) (move down)
    photo 4 (move up) (move down)

    and you click on move down on photo 3, the new order would be

    photo 1 (move up) (move down)
    photo 2 (move up) (move down)
    photo 4 (move up) (move down)
    photo 3 (move up) (move down)


    Im guessing it has some sort of number game to get this working.. but I cant figure out how to make it consistently work..

    at first i was thinking of each photo haveing a number assigned to it, and when a photo gets moved up, just check the next highest number, and the one higher than that, and then jump in the middle of the two.. but after you do that a few times, the gap gets smaller and smaller...so yeah?
    haha


    Can anyone help me?

    thanks!

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    a bit more than you asked for, but maybe it will be useful to you.
    http://www.phpriot.com/d/articles/cl...jax/index.html


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •