Jump to content


Photo

need help on on this problem


  • Please log in to reply
5 replies to this topic

#1 darkcarnival

darkcarnival
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 08 May 2006 - 09:19 PM

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

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 08 May 2006 - 09:31 PM

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...
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 08 May 2006 - 09:37 PM

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.

#4 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 08 May 2006 - 09:43 PM

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.
Legend has it that reading the manual never killed anyone.
My site

#5 darkcarnival

darkcarnival
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 08 May 2006 - 10:08 PM

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.

#6 darkcarnival

darkcarnival
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 11 May 2006 - 01:59 AM

ok i figued this out :)

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

thanks to those who replied.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users