I think we are on the same page here. That looks alot like a bubble sort. Any way to wrap that up in a function? And can you explain the code a little bit. Sorry for asking for so much, but I will have a hard time getting it done if I don't know what im doing
edit: Also! There is a unique id for each clan and you were right. It is clan_id.
edit2:
Although I really don't see a point on having a column for the clan rank.. it makes a lot more sense to compute the order through the select query much like I have done in the above $sql.
Because I have other pages that look for the clans rank.
Here check out the page. You can probably follow along with what im doing fairly easy.
http://www.aowars.com
also, I uploaded your script to a test.php file. Have a look~
http://www.aowars.com/modules.php?name= ... test&lid=1
Here is the code. I don't know why it results in an error:
Code: Select all
<?
/* require_once("modules/League/includes/league_functions.php");
$current_ladder = $_GET[lid];
$ladder = sql_query("SELECT ladder_id, ladder_name, ladder_directory, sql_db, sql_username, sql_pw, sql_prefix FROM ".$prefix."_league_ladders WHERE ladder_id = $current_ladder");
list($ladder_id, $ladder_name, $ladder_directory, $sql_db, $sql_username, $sql_pw, $sql_prefix) = sql_fetch_row($ladder);
connection($sql_db, $sql_username, $sql_pw);*/
$sql = '
SELECT *
FROM `halo_clans`
ORDER BY `clan_points`, `clan_wins`DESC';
$result = mysql_query($result) or die('SQL ['.$sql.'] caused: '. mysql_error());
//assuming you have a unique id for each clan
while ($row = mysql_fetch_assoc($result)) {
$clans[] = $row['clan_id'];
}
for ($x = 0; $x <= 15; $x ++) {
$sql = '
UPDATE `halo_clans`
SET `clank_rank` = \''.($x+1).'\'
WHERE `clan_id` = \''.$clans[$x].'\'
LIMIT 1';
$result = mysql_query($result) or die('SQL ['.$sql.'] caused: '. mysql_error());
}
?>