Reply to Re: [PHP] swaping mysql table values

Your name:

Reply:


Posted by Jochem Maas on 03/05/05 14:38

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
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация