Picture gallery - sorting

Discussion in 'PHP' started by PoPSiCLe, Apr 17, 2009.

  1. #1
    Hey.

    I have been working on a picture gallery on a page I'm managing/making, and while I have the basic functions working (adding pictures, subfolders, adding thumbs and medium sized images, adding the picture-names and -paths to the database, etc.) I have yet to find a good way to sort and not to mention re-sort the pictures.

    What I would like is for the user (admin, not everyone) to be able to re-sort the pictures in the database. The pictures are added more or less randomly (by reading a folder, and adding the array of filenames retrieved to the database).

    I was thinking of adding another row to the database-table, and then use that value to sort the pictures. Now, as to how and what, and how to implement, I'm a bit at a loss.

    I was thinking I could add another unique INT-column, and then pull all the pics from the database, (thumbs), with the value currently assigned to each picture next to it. What I would like, though, is for the user to be able to use a sort of "up" and "down" rating for each picture, so he/she can re-sort the pictures. Say if the last picture on the list, with the value "84" should really be number "3" in the sort order - the user would then be able to enter "3" in the box, and the rest of the pictures (from "3" onward) should re-sort to start from "4" and so on. If the user wants to change the sort order from "84" to "83", say, it should just be to click a button to "up" the image a bit. Is this possible in any way? I'm wondering if I should maybe post this in the javascript forum as well, as I'm thinking I need some sort of javascript to make this work without having to continuously reload the page?

    Any tips, classes, functions etc. for doing this would be much appreciated!
     
    PoPSiCLe, Apr 17, 2009 IP