| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| New Member Join Date: Jul 2004 Location: Miami, Florda
Posts: 23
![]() | Creating ranks with 2 ranks...? Never really done this before, but i got as far as usort, and then kinda just lost it. What im trying to do, is upgrade users ranks by 2 numbers. user 1 - 1:2 user 2 - 3:3 user 3 - 2:1 User 1 would be ranked 1st User 2 would be ranked 3rd User 3 would be ranked 1st, but would show 2nd by default cause user 1 comes before user 3. Anyway, so i have a table called "users", with the 3 fields "rank, attackrank, defencerank" I want to upgrade their ranks by attackrank and defencerank. Not sure if im making sense.
__________________ Wanna buy a game source code? Just PM me. Dopewars Clone - 3 copies left Kings of Chaos V2 Clone - 4 copies left and Rise of Chaos - 1 copy left Pimpgame V6 Clone - 3 copies left (based on pimpwar) |
| |
| | #2 (permalink) |
| NamePros Admin ![]() ![]() ![]() Join Date: Feb 2003
Posts: 12,919
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Let me see if I understand it right. You have two independent rankings already. You want to then average the two ranking systems into one "master rank" ? If the two original rankings are considered equally, couldn't you just add the two rankings together and then assign the new rank based on this combined score (1st - lowest combined total) ?
__________________ Reach me at rj at namepros dot com |
| |
| | THREAD STARTER #3 (permalink) |
| New Member Join Date: Jul 2004 Location: Miami, Florda
Posts: 23
![]() | Yea, thats exactly what i did. Code: $get = mysql_query("SELECT id,name,((damrank + defrank) / 2) AS avgrank FROM $tab[player] ORDER BY avgrank ASC;");
$rank = 0;
while ($user = mysql_fetch_array($get))
{
$rank++;
mysql_query("UPDATE $tab[player] SET rank='$rank' WHERE id=$user[id];");
}
__________________ Wanna buy a game source code? Just PM me. Dopewars Clone - 3 copies left Kings of Chaos V2 Clone - 4 copies left and Rise of Chaos - 1 copy left Pimpgame V6 Clone - 3 copies left (based on pimpwar) |
| |