Re: swaping mysql table values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dave Carrera wrote:
Hi List,

I have a table like the diag below:

ID Name Pos
1  jig  1
2  pig  2
3  dig  3
4  fig  4

What i am trying to do is upon click to change pos 1 to pos 2 and pos 2 to pos 1so that i can manage the position i show my list.

Can someone throw me some nuggets of logic wisdom as my searchs are coming up blank.

here is a description of a simple ordering mechanism, hope it gives you an idea how to proceed:

1. output a table that reflects the current order.
   each row should have (at least) 2 links: 'move up' & 'move down',
   the links should have GET params for the direction you want to the
   position to change to and the id of the item whose position you want to
   change.

2. if a user clicks on one of those links do the following processing:

   MOVE DOWN:
	1. determine the selected items current 'position'
        2. find the item whose 'position' is the next greatest (value) after
           the selected items 'position'	
	3. if an item with greater 'position' is found then do:
		a, update selected items position with position value of item found
                   in step 2
		b, update the 'position' of the item found in step 2 with the 'position'
	           value of the selected item.
   MOVE UP:
	1. determine the selected items current 'position'
        2. find the item whose 'position' is the next lowest (value) after
           the selected items 'position'	
	3. if an item with lesser 'position' is found then do:
		a, update selected items position with position value of item found
                   in step 2
		b, update the 'position' of the item found in step 2 with the 'position'
	           value of the selected item.

3. go back to step 1. (output a table!)


Thanks you in advance

Dave C


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux