darkcarnival Posted May 8, 2006 Share Posted May 8, 2006 not sure how to word this but basically Im working on a way to automate the way I order up the categories for a script of mine.the way its written now is that i punch in the number and have to do edit a few items beefore it actually moves up.now what i want to do is make a link that will either move the item up or down(depending on what link is clicked) and when the link is clicked the item will move up or down.basically how you move the forums & catories in phpbb. you click on move up and the item moves up.any idea on how to do that?thanks :) Quote Link to comment https://forums.phpfreaks.com/topic/9342-need-help-on-on-this-problem/ Share on other sites More sharing options...
.josh Posted May 8, 2006 Share Posted May 8, 2006 you would think there would be some kind of sql command to do it directly to the rows in the table, but i can't think of one off the top of my head. the only thing i can think off the top of my head is to create an array of all the rows in your table and push the data up one position in the array, delete and then re-insert the rows. but i forsee lots of problems with this. 1) would be very time consuming if you had a large table. 2) if you have unique columns, all of the data for those columns will change. i'm sure there has GOT to be some kind of simple sql command for that... Quote Link to comment https://forums.phpfreaks.com/topic/9342-need-help-on-on-this-problem/#findComment-34430 Share on other sites More sharing options...
wildteen88 Posted May 8, 2006 Share Posted May 8, 2006 Basically I think in the forum table in the database there is a table row called order.Then when you click a link it increases or decreases the number of the forum order up/down by one and then uses the ORDER BY clause in the query to order by forum order.having a look at code may help clear up what I mean and having a look at the database structure. Quote Link to comment https://forums.phpfreaks.com/topic/9342-need-help-on-on-this-problem/#findComment-34433 Share on other sites More sharing options...
AndyB Posted May 8, 2006 Share Posted May 8, 2006 The way I'd approach it is to maintain a small file/table containing the order/position and an xref to each category. Read that information into an array.Using the array info, display categories in my selected order.As I click the move up/move down buttons, array variables are exchanged and the list is redrawn.When it's all in the order I want, click 'save' to write the small file/table with the new order in which categories are to be displayed.There's no need to make changes to database tables other than the one that contains category # and position in the list. Quote Link to comment https://forums.phpfreaks.com/topic/9342-need-help-on-on-this-problem/#findComment-34439 Share on other sites More sharing options...
darkcarnival Posted May 8, 2006 Author Share Posted May 8, 2006 well really what I wanted to do is something like this:category name [txtbox to enter number]and but i have not found any kind of help on doing that sadly.but what if order is a number you either add to or subtract from a certain number.like to go up add by 7 and when to go down substract by 3 or something like that. it would have to be a way that the numbers would never match up. Quote Link to comment https://forums.phpfreaks.com/topic/9342-need-help-on-on-this-problem/#findComment-34445 Share on other sites More sharing options...
darkcarnival Posted May 11, 2006 Author Share Posted May 11, 2006 ok i figued this out :)took some work but i found a way to make the ordering system automated.thanks to those who replied. Quote Link to comment https://forums.phpfreaks.com/topic/9342-need-help-on-on-this-problem/#findComment-35133 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.