stb74 Posted January 22, 2007 Share Posted January 22, 2007 I have a page that I export divisions from a league one after each other to a text file.I can get it to export the data but once I add the array_multisort some teams are placed in the wrong division. It works fine for one division then I added the code following code so I can export each division in the league. Can anyone see whats wrong with the array_mulitsort.[code]do{} $defaultdivisionid++;} while ($row_divisions = mysql_fetch_assoc($divisions));[/code]Complete Code[code]<?php session_start();//Connect to the database and select used databaserequire('../dbconnect/config.php');require('../dbconnect/dbconnect.php');header ("Content-type: application/csv");header ("Content-Disposition: inline; filename=$row_filename[name]_tables.txt");do{ // Column Headers echo("Team\t"); echo("P\t"); echo("W\t"); echo("D\t"); echo("L\t"); echo("F\t"); echo("A\t"); echo("Pts\t\n"); // Get Match Teams for selected Division & Season. mysql_select_db("$dbname", $dbconnect); $query_get_teams = " SELECT DISTINCT O.teamName AS name, O.teamID AS id FROM leaguestats_teams O, leaguestats_matches LM WHERE LM.matchSeasonID LIKE '$defaultseasonid' AND LM.matchdivisionID = '$defaultdivisionid' AND (O.teamID = LM.matchHomeID OR O.teamID = LM.matchAwayID)"; $get_teams = mysql_query($query_get_teams, $dbconnect) or die(mysql_error()); $row_get_teams = mysql_fetch_assoc($get_teams); $totalRows_get_teams = mysql_num_rows($get_teams); // End Get Match Teams for selected Division & Season. // Start Loop and read teams in to Table. $i = 0; do { $team[$i] = $row_get_teams['name']; $teamid[$i] = $row_get_teams['id']; //$teamstatus[$i] = $row_get_teams['status']; Get data to calculate points etc.... $points[$i] = $temp_points + ($wins[$i]*$for_win) + ($draws[$i]*$for_draw); $pld[$i] = $homewins[$i]+$homedraws[$i]+$homeloses[$i]+$awaywins[$i]+$awaydraws[$i]+$awayloses[$i]; $diff[$i] = ($homegoals[$i] + $awaygoals[$i]) - ($homegoalsagainst[$i] + $awaygoalsagainst[$i]); $i++; } while($row_get_teams = mysql_fetch_assoc($get_teams)); // End Loop and read teams in to Table. $qty = $totalRows_get_teams; // Sort By Pointsarray_multisort($points, SORT_DESC, SORT_NUMERIC, $diff, SORT_DESC, SORT_NUMERIC, $goals_for, SORT_DESC, SORT_NUMERIC, $wins, SORT_DESC, SORT_NUMERIC, $goals_against, SORT_ASC, SORT_NUMERIC, $draws, $loses, $pld, SORT_DESC, SORT_NUMERIC, $team, $homewins, $homedraws, $homeloses, $awaywins, $awaydraws, $awayloses, $homegoals, $homegoalsagainst, $awaygoals, $awaygoalsagainst); $i=0; while($i < $qty) { echo "$team[$i]\t"; echo "$pld[$i]\t"; echo"$wins[$i]\t"; echo"$draws[$i]\t"; echo"$loses[$i]\t"; echo"$goals_for[$i]\t"; echo"$goals_against[$i]\t"; echo"$points[$i]\t"; $i++; echo "\n"; } echo "\n"; $defaultdivisionid++;} while ($row_divisions = mysql_fetch_assoc($divisions));?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/35259-array_multisort-export/ Share on other sites More sharing options...
fenway Posted January 22, 2007 Share Posted January 22, 2007 No idea, but you might get more help elsewhere... isn't that php function? Quote Link to comment https://forums.phpfreaks.com/topic/35259-array_multisort-export/#findComment-166745 Share on other sites More sharing options...
bibby Posted January 23, 2007 Share Posted January 23, 2007 The comany I work for wrote their own multi sort.PHP's array_multisort() is pretty sketchy. Quote Link to comment https://forums.phpfreaks.com/topic/35259-array_multisort-export/#findComment-166979 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.