Hi!

Could someone show me how to implement swap algorithm in php and mysql?

ie:

I have 4 records in a table

each are sorted by column position

say position 1 2 3 4

if I move an existing position from 4 to 1

number 1 will be moved to number 2

number 2 will be moved to number 3

number 3 will be moved to number 4

the the data that I want to move which is number 4

can now take the place of number 1

is there any other algorithm I can use instead of the one I already implemented but not working by the way

heres the post remained unsolved.

http://www.daniweb.com/web-development/php/threads/414267

thanks in advance!

Hi!

Could someone show me how to implement swap algorithm in php and mysql?

ie:

I have 4 records in a table

each are sorted by column position

say position 1 2 3 4

if I move an existing position from 4 to 1

number 1 will be moved to number 2

number 2 will be moved to number 3

number 3 will be moved to number 4

the the data that I want to move which is number 4

can now take the place of number 1

is there any other algorithm I can use instead of the one I already implemented but not working by the way

heres the post remained unsolved.

http://www.daniweb.com/web-development/php/threads/414267

thanks in advance!

1. First save all the element in array. then

http://www.php.net/manual/en/function.array-reverse.php

2. use about array reverse and save it to another array.

3. And do the query to database for update.

This is the easiest way.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.