order by problem
-
I have a page that displays 2 lists of names and a squad number next to them. the awayteam part of the page displays and sorts fine but the hometeam part of page doesnt sort. code below the bold bit is the part that doesnt sort
mysql_select_db($database_newleague, $newleague);
$query_rsHometeam = "SELECT teamid.teamname AS hometeamname, players.squadnumber, players.playername FROM players INNER JOIN teams AS teamid ON teamid.teamid = players.teamid WHERE players.homeaway='h' AND players.playing=1 ORDER BY position ASC, squadnumber ASC ";
$rsHometeam = mysql_query($query_rsHometeam, $newleague) or die(mysql_error());
$row_rsHometeam = mysql_fetch_assoc($rsHometeam);
$totalRows_rsHometeam = mysql_num_rows($rsHometeam);mysql_select_db($database_newleague, $newleague);
$query_rsAwayteam = "SELECT teamid.teamname AS awayteamname, players.squadnumber, players.playername FROM players INNER JOIN teams AS teamid ON teamid.teamid = players.teamid WHERE players.homeaway='a' AND players.playing=1 ORDER BY position ASC, squadnumber ASC ";
$rsAwayteam = mysql_query($query_rsAwayteam, $newleague) or die(mysql_error());
$row_rsAwayteam = mysql_fetch_assoc($rsAwayteam);
$totalRows_rsAwayteam = mysql_num_rows($rsAwayteam); -
I have a page that displays 2 lists of names and a squad number next to them. the awayteam part of the page displays and sorts fine but the hometeam part of page doesnt sort. code below the bold bit is the part that doesnt sort
mysql_select_db($database_newleague, $newleague);
$query_rsHometeam = "SELECT teamid.teamname AS hometeamname, players.squadnumber, players.playername FROM players INNER JOIN teams AS teamid ON teamid.teamid = players.teamid WHERE players.homeaway='h' AND players.playing=1 ORDER BY position ASC, squadnumber ASC ";
$rsHometeam = mysql_query($query_rsHometeam, $newleague) or die(mysql_error());
$row_rsHometeam = mysql_fetch_assoc($rsHometeam);
$totalRows_rsHometeam = mysql_num_rows($rsHometeam);mysql_select_db($database_newleague, $newleague);
$query_rsAwayteam = "SELECT teamid.teamname AS awayteamname, players.squadnumber, players.playername FROM players INNER JOIN teams AS teamid ON teamid.teamid = players.teamid WHERE players.homeaway='a' AND players.playing=1 ORDER BY position ASC, squadnumber ASC ";
$rsAwayteam = mysql_query($query_rsAwayteam, $newleague) or die(mysql_error());
$row_rsAwayteam = mysql_fetch_assoc($rsAwayteam);
$totalRows_rsAwayteam = mysql_num_rows($rsAwayteam);kennyhibs wrote:
ORDER BY position ASC, squadnumber ASC
"So the records are ordered by position and then within that by squad number. I am guessing this sort order is the problem, check the values held in both fields.
Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
-
kennyhibs wrote:
ORDER BY position ASC, squadnumber ASC
"So the records are ordered by position and then within that by squad number. I am guessing this sort order is the problem, check the values held in both fields.
Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett