Jump to content

Archived

This topic is now archived and is closed to further replies.

darkcarnival

need help on on this problem

Recommended Posts

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 :)

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
ok i figued this out :)

took some work but i found a way to make the ordering system automated.

thanks to those who replied.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.