rreynier Posted July 31, 2009 Share Posted July 31, 2009 Hey guys, I have created a little CMS project. There are several cases where I have content that needs to be able to be moved to the top or down.. etc. Right now, I just asdded a field called "order" and all my sql queries are doing "ORDER BY `order` ASC" The way to change order is just to have the user change the number manually when editting the item.. So if you have 2 items.. one with the value 50 will be at bottom and one with value of 1, will be at the top. I would like the user instead of having to put in a number in an input field, just be able to hit "move up" or "move down". My question is, how would I go about this. Im having a brainfree on how to do this logically. Thanks ahead of time! Link to comment https://forums.phpfreaks.com/topic/168320-solved-changing-order-of-items-in-cms-help-with-logic/ Share on other sites More sharing options...
phpknight Posted August 1, 2009 Share Posted August 1, 2009 If they click move up, then find the one above it the one below it. Then divide by two, and use the middle value. So, if one is 10 and the other is 20, make it 15. You can then infinitely have the order by using a float or double for the field instead of an int. Link to comment https://forums.phpfreaks.com/topic/168320-solved-changing-order-of-items-in-cms-help-with-logic/#findComment-888111 Share on other sites More sharing options...
rreynier Posted August 3, 2009 Author Share Posted August 3, 2009 So, if the user clicks "move item up in order" find the next 2 entries that are higher in the list. Add them together and divide by two? So lets say the order value item is 16 and the next two are 17 and 18, I would get 17.5. Could this possibly get out of hand decimal point wise? Link to comment https://forums.phpfreaks.com/topic/168320-solved-changing-order-of-items-in-cms-help-with-logic/#findComment-889613 Share on other sites More sharing options...
rreynier Posted August 3, 2009 Author Share Posted August 3, 2009 does anyone have any other methods, or is this the basic idea used in these types of systems? Link to comment https://forums.phpfreaks.com/topic/168320-solved-changing-order-of-items-in-cms-help-with-logic/#findComment-889712 Share on other sites More sharing options...
phpknight Posted August 3, 2009 Share Posted August 3, 2009 It doesn't matter what the decimal points look like because all you care about is the ordering. So, I wouldn't worry about it. BUT, if you want, you could reset them every week or something to be multiples of 10. Link to comment https://forums.phpfreaks.com/topic/168320-solved-changing-order-of-items-in-cms-help-with-logic/#findComment-889790 Share on other sites More sharing options...
rreynier Posted August 4, 2009 Author Share Posted August 4, 2009 ok cool. i will use your concept, thanks alot phpknight Link to comment https://forums.phpfreaks.com/topic/168320-solved-changing-order-of-items-in-cms-help-with-logic/#findComment-890534 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.