First off, thank you Miguel and Nathan for responding. The ordering changes. Here is what I have for my query: $searchStmt="Select * from $temp2 where sea_id = '$sea_id' order by pts DESC"; if($aa){$searchStmt .= ",$aa DESC";} if($bb){$searchStmt .= ",$bb DESC";} if($cc){$searchStmt .= ",$cc DESC";} if($dd){$searchStmt .= ",$dd DESC";} $searchStmt .= ",name ASC";
$aa, $bb, $cc and $dd will change depending on how the division does their ranking. For the most part, I can sort with the mysql query as above. There is one variable that can't be sorted (at least I was told it can't), by this query. If there is a tie, I have to check to see if the teams have played each other and if they have, than whomever won that game will be ahead in the rankings. Nathan, on this list, suggested using a loop for this. I am not that proficient in PHP to do that. I could probably do that if there would only be two teams that might be in a tie, but you actually can have multiple ties for positions and/or more than 2 teams tieing for one position. I have to program with the possibility that all teams can tie and than it has to loop through and get the games by who won in a one on one game. Thanks Steve At 04:03 PM 4/25/2002, Miguel Cruz wrote: >On Thu, 25 Apr 2002, Steve Buehler wrote: > > I am using PHP to access a mysql database. I was told that what I need to > > do needs to be done in PHP and not mysql. I can get mysql to order things > > like this: > > Select * from $temp2 where sea_id = '$sea_id' order by pts DESC > > The problem is that if there is a tie (as in ranking 4 and 5 below), I > need > > to run another query to check to see if something else has happened and if > > it happened, than that team would be a higher rank than the other. It is > > possible to have more than 2 teams tieing too. So I have to be able to > > determine what order the teams should be in. > >Well, we don't know what the secondary sorting criterion is, but my guess >is that you could have your database take care of that too in the same >query. > >miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php