Here's the thing. I need to create a sorting script. I need some serious help.
Basically there's a news script that's displayed and I need to add a textbox (it must be a textbox) so that the user is able to sort the news out (with integers, 1 to $counter).
Till here fine, I have the values stored in a MySql db and I can get / update them just fine. The problem is that I have to:
a) Check for double used values and AUTOMATICALLY correct them. Eg: news1 - position7, news6 - position 7 -> would end up position 7 / 8 respectively.
b) Store the new values (or just the changed ones, I can add a hidden field with the old value for comparison) into the db.
I have no idea of how to validate a).
I also thought of a mathematical solution that involved subtracting the old_value from the new_value, if it yields a positive number it changes values of the fields in between and changes the values of all the fields after the old_value. If it yields a negative value, it changes the values after new_value and subtracts a value from old_value+difference.
It's a mess and I have no idea of how to do this.
Many thanks for the help.
Big small problem.
Moderator: General Moderators
So basically you you want:
And so on, so if you changed these values:
Then you press update, it would make the listing:
Did I get that right?
Code: Select all
NAME POSITION
News Article1 [__1__]
News Article2 [__2__]
News Article3 [__3__]
News Article4 [__4__]
News Article5 [__5__]
News Article6 [__6__]
News Article7 [__7__]
News Article8 [__8__]Code: Select all
NAME POSITION
News Article1 [__1__]
News Article2 [__7__]
News Article3 [__3__]
News Article4 [__4__]
News Article5 [__3__]
News Article6 [__6__]
News Article7 [__7__]
News Article8 [__8__]Code: Select all
NAME POSITION
News Article1 [__1__]
News Article3 [__2__]
News Article5 [__3__]
News Article4 [__4__]
News Article6 [__5__]
News Article2 [__6__]
News Article7 [__7__]
News Article8 [__8__]- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Maybe try sorting the array instead of in the database.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
There are a bunch of array functins to choose from. Read the array section of the PHP manual for a list of array functions.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
deleet, you waited just over 12 hours to bump your thread. This is against forum rules. Do not do it again.
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:4. All users of any level are restricted to bumping (as defined here) any given thread within twenty-four (24) hours of its last post. Non-trivial posts are not considered bumping. A bump post found in violation will be deleted, and you may or may not recieve a warning. Persons bumping excessively be considered as spammers and dealt with accordingly.