Hola!
I'm writing a small classified advertising website.
Most of it is done, and I'm just working out the kinks of the photo management component I've written. For the most part it works.
User Functions, Functioning:
-upload up to 20 photos one by one
-upload up to 20 photos in one form (multiples)
-re-arrange photo order (move up, move down)
-delete photos one by one
-delete photos in multiples
-add/edit captions
-set any photo as primary for the classified ad
-bulk edit (select check box of each photo to bulk edit)
Back end Functions, Functioning:
-auto resize of original photo into thumbnail, small, medium, and large versions
-auto delete of original photo after mod versions created
-basic consolidation after photos deleted.. Delete photo with position 17, photo with position 18 gets 17. prevents gaps in positioning
I still need help with two things. I'm not looking for advice on table structure or anything like, just programmatic advice on how to best achieve the results I want.
Here is the table structure:
tbl_classified_photos
classified_photo_id (int-identity-pk)
classified_id (int-fk)
classified_photo_public_url (varchar-255)
classified_photo_private_url (varchar-255)
classified_photo_file (varchar-255)
classified_photo_caption (nvchar-16-null)
classified_photo_file_created (datetime-null)
classified_photo_file_created_ip (varchar-15-null)
classified_photo_file_last_modified (datetime-null)
classified_photo_file_last_modified_ip (varchar-15-null)
classified_photo_position (smallint-2)
First Issue:
Right now, when a photo is deleted, the order is consolidated to make up for the gap of the delete photos. Basically, just after the query runs that deletes the photo, another query runs that sets the position to -1 of whatever photo had a position greater than the position of the photo that was deleted. That works.
What doesn't work is if their is already some kind of gap in positioning. Such as there are photos with positions 1,2,3,4,6,9. I've put measures in place to prevent that from even happening, but if it does, I want a function in place that fixes it. Does anybody know of the best way to get the set in order?
If I run a query and get the following positions
1,2,3,5,9,15
How can I convert that to
1,2,3,4,5,6
I'm writing a small classified advertising website.
Most of it is done, and I'm just working out the kinks of the photo management component I've written. For the most part it works.
User Functions, Functioning:
-upload up to 20 photos one by one
-upload up to 20 photos in one form (multiples)
-re-arrange photo order (move up, move down)
-delete photos one by one
-delete photos in multiples
-add/edit captions
-set any photo as primary for the classified ad
-bulk edit (select check box of each photo to bulk edit)
Back end Functions, Functioning:
-auto resize of original photo into thumbnail, small, medium, and large versions
-auto delete of original photo after mod versions created
-basic consolidation after photos deleted.. Delete photo with position 17, photo with position 18 gets 17. prevents gaps in positioning
I still need help with two things. I'm not looking for advice on table structure or anything like, just programmatic advice on how to best achieve the results I want.
Here is the table structure:
tbl_classified_photos
classified_photo_id (int-identity-pk)
classified_id (int-fk)
classified_photo_public_url (varchar-255)
classified_photo_private_url (varchar-255)
classified_photo_file (varchar-255)
classified_photo_caption (nvchar-16-null)
classified_photo_file_created (datetime-null)
classified_photo_file_created_ip (varchar-15-null)
classified_photo_file_last_modified (datetime-null)
classified_photo_file_last_modified_ip (varchar-15-null)
classified_photo_position (smallint-2)
First Issue:
Right now, when a photo is deleted, the order is consolidated to make up for the gap of the delete photos. Basically, just after the query runs that deletes the photo, another query runs that sets the position to -1 of whatever photo had a position greater than the position of the photo that was deleted. That works.
What doesn't work is if their is already some kind of gap in positioning. Such as there are photos with positions 1,2,3,4,6,9. I've put measures in place to prevent that from even happening, but if it does, I want a function in place that fixes it. Does anybody know of the best way to get the set in order?
If I run a query and get the following positions
1,2,3,5,9,15
How can I convert that to
1,2,3,4,5,6