Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. MySQL
  4. order by problem

order by problem

Scheduled Pinned Locked Moved MySQL
databasesharepointmysqlhelp
3 Posts 2 Posters 19 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kennyhibs
    wrote on last edited by
    #1

    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);

    N 1 Reply Last reply
    0
    • K kennyhibs

      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);

      N Offline
      N Offline
      Nagy Vilmos
      wrote on last edited by
      #2

      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

      K 1 Reply Last reply
      0
      • N Nagy Vilmos

        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

        K Offline
        K Offline
        kennyhibs
        wrote on last edited by
        #3

        the bottom part of code (awayteam) uses same table in database and sorts correctly so values are correct, for some reason home team doesnt sort

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups