Dynamic sorting by user in page
Posted: Mon Oct 04, 2010 7:58 am
Hello!
I've got a site that has a dashboard where the user can log into and manage photos that they've uploaded. The user asked me, the other day, if there's a way to sort the images and what order they're displayed on the actual site. First, I'll explain the process the images go through from upload to displaying on the site:
-Upload file via upload form
-ID, Filename, Title, Category, and SortOrder are inserted to database (user defined except ID and Filename)
-Image is uploaded to directory (filename matches database)
-Call while(mysql_fetch_array) statement to display all images in specified category
-Sort by user specified SortOrder in ASC order
So, as you can see I've got a temporary solution for sorting where the user can assign a number to each image and then call a SELECT statement sorting in ASC order. The problem comes in when the user has 50 or so images per category and wants to add a picture to the top of the list. Then they would have to either have multiples with the same number or would have to re-number everything to allow that image to squeeze in.
Bottom line: Does anyone have any auggestions as to how I can create a dynamic sorting script where, when they want to add an image to the top, they don't have to go back in and re-number everything beneath thato one?
Let me know if you need an example of the code altough I don't know how much it would help It's more of a theory question.
I've got a site that has a dashboard where the user can log into and manage photos that they've uploaded. The user asked me, the other day, if there's a way to sort the images and what order they're displayed on the actual site. First, I'll explain the process the images go through from upload to displaying on the site:
-Upload file via upload form
-ID, Filename, Title, Category, and SortOrder are inserted to database (user defined except ID and Filename)
-Image is uploaded to directory (filename matches database)
-Call while(mysql_fetch_array) statement to display all images in specified category
-Sort by user specified SortOrder in ASC order
So, as you can see I've got a temporary solution for sorting where the user can assign a number to each image and then call a SELECT statement sorting in ASC order. The problem comes in when the user has 50 or so images per category and wants to add a picture to the top of the list. Then they would have to either have multiples with the same number or would have to re-number everything to allow that image to squeeze in.
Bottom line: Does anyone have any auggestions as to how I can create a dynamic sorting script where, when they want to add an image to the top, they don't have to go back in and re-number everything beneath thato one?
Let me know if you need an example of the code altough I don't know how much it would help It's more of a theory question.