| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| is on hiatus Join Date: May 2006
Posts: 2,453
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | PHP/MySQL: How to sort with custom rank settings How to sort with custom ranks? Ex: I have 1 2 3 4 And I want to update the ranks to 1 3 2 4, how would I update this? Using move up and down? Thanks, AzN
__________________ Currently on hiatus. Back whenever. |
| |
| | #2 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,069
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | how are they stored? How are you determining which order they should be in?
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| |
| | #3 (permalink) |
| Senior Member Join Date: Jul 2005 Location: NJ
Posts: 1,219
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | well you should have a key field with ID and then probably another field of "rank" which are numbers which you probably update manually or whatever. just add ORDER BY rank ASC at the end of your sql statement and it'll order them for you. don't bother moving the entries aruond, cuz that'll take wayyy too many resources, especially if u get a large db. edit: actually, after rereading your post, i think the proper sql command you're looking for is UPDATE. make sure you have a primary key field of id which autoincrements or w/e and then u can do an UPDATE command. google the exact syntax, i never get it perfectly right...
__________________ Hacksar.com - Your source for random computer tips and tricks! MySiteMemberships.com - Keep track of your site registration information! Like my post? Rep is appreciated! |
| |