How about just assigning every image with a sequetial integer and for
updating just do swaps with the IDs, sort of like a bubble sort.

for reordering use a bit of CSS and javascript and have each of your images
as a span with an onclick which highlights that image to show its selected.
Between each element have an arrow of some type which is basically a "insert
here"

>
 -------image-------
>
 -------image-------
>
 -------image-------
>

etc.

when an image is selected and one of the arrows is clicked you need to do
your updating.
In your database say you have

imagename | orderID
a               1
b               2
c               3
d               4
e               5
f               6

where imagename is your primary key
now if you wanted to move f to be just below b you would have to have an
UPDATE statement like

UPDATE table
SET orderID = orderID + 1
WHERE orderID > (SELECT orderID FROM table WHERE imagename = 'b')

UPDATE table
SET orderID = (SELECT orderID FROM table WHERE imagename = 'b')+ 1
WHERE imagename = 'f'

You would need to also have a case where you want to move in the other
direction.
This hasnt been tested, just an idea.

regards,

Gunther

-----Original Message-----
From: mayo [mailto:[EMAIL PROTECTED]
Sent: Thursday, 18 September 2003 11:02 AM
To: CF-Talk
Subject: order and re-oder 


I would like to be able let a user reorder photographs.

Grouping them by type is not the issue, (fashion, runway, nature, etc...) or
by subcategory (fashion_gender, runway_designer)

The user wants to be able to add new photographs and reorder them so that
prefered photos come first.

My first thought is to have a photoOrder field which the user can update
with an admin screen (simplified) something like the following:

photoOrder Number --- photo

10 ------------------ [img]
15 ------------------ [img]
20 ------------------ [img]

The user can update the 10 (it's in a text field) to a 21 and have the first
photo appear last. With only a few graphics in each sub category this can
work fairly well --- but it's REALLY UGLY.

Better yet would be to be able to move the graphic
1. up or down with an arrow (for one at a time)
2. send to end / beginning
3. have a text box to send a specified amount up or down.

A simplified example below:

<<  < [insert amount] >  >>

I can think of a way to update the records for this to work but eventually
it would be a real big mess.

User moves number 33 to behind 55.
        If 56 is there the photoOrder gets designated 55a
        55b comes after 55a

        (55,55a,55b,56)

Now with only a few photos, or even a few dozen photos who cares. But in a
more involved system one would get situation like the following

        (55a1,55a2,55a3,55a4,55a5)
        (55a2a,55a2b,55a2c,55a2d)

This is ridiculous.( or is it?)

Is there a way to reorder/organize this field?

to take a sorted list(of this field) 1-77-203-204-999 and make it
10,20,30,40,50 or (1000,2000,3000)

Gilbert Midonnet













~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm?link=i:4:137418
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
http://www.cfhosting.com

Reply via email to