League Table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mtgriffiths86
    New Member
    • Jan 2008
    • 13

    League Table

    Where do i begin...well

    I am attempting to build a league management website that will automatically work out league tables, fixtures and results.

    The first problem that i have is this:

    To automaticaaly work out the fixtures i plan on having the highest point scorers from the previous month to play against the 2nd highest point scores and 3rd v 4th and so on.

    Im not sure how to take the data from my database and input the information into the correct place so that the team names show correctly each week.

    Can anybody please help me?

    Thanks in advance

    Matthew
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    Originally posted by mtgriffiths86
    Where do i begin...well

    I am attempting to build a league management website that will automatically work out league tables, fixtures and results.

    The first problem that i have is this:

    To automaticaaly work out the fixtures i plan on having the highest point scorers from the previous month to play against the 2nd highest point scores and 3rd v 4th and so on.

    Im not sure how to take the data from my database and input the information into the correct place so that the team names show correctly each week.

    Can anybody please help me?

    Thanks in advance

    Matthew
    Could you explain more on how the process works more in detail.

    Do you have a match schedule of days already?

    The team that ranks the lowest will be dropped out?

    Say we have 10 teams, how would the first round work? , randomly pair up teams?

    Of those 10 we get five teams, and of those we get 2.5 teams?

    we're programmers, we don't (atleast i) don't have a clue about how sports work.

    Comment

    • ak1dnar
      Recognized Expert Top Contributor
      • Jan 2007
      • 1584

      #3
      Really I also don't have a idea about the game. but it's better if you can create a diagram first, to identify the flow of the system.

      Comment

      • mtgriffiths86
        New Member
        • Jan 2008
        • 13

        #4
        Thanks for the replies...

        Firstly there are 3 leagues with say 6 teams in each league.

        To work out what teams are playing weekly i want to automatically work it out by how many points they have. For example:

        1st vs 2nd
        3rd vs 4th
        5th vs 6th

        The following week will be

        1st vs 3rd
        2nd vs 5th
        3rd vs 6th

        and so on like that.

        I have to look into the database that i have with the points field, check the who has the most to least then input the teams name (which is in the same database as points) in to a format something like this

        _____________ VS _______________ __ where the blanks are filled in automatically.

        Hope that description helps a lil more

        Thanks again

        Matthew

        Comment

        • mtgriffiths86
          New Member
          • Jan 2008
          • 13

          #5
          This is what i am currently trying to use.

          <?php

          //opening the database
          $host="localhos t"; // Host name
          $username="root "; // Mysql username
          $password=""; // Mysql password
          $db_name="leagu e_table"; // Database name
          $tbl_name="leag ue_2"; // Table name

          // Connect to server and select databse.
          $link=mysql_con nect("$host", "$username" , "$password" )or die("cannot connect");
          mysql_select_db ("$db_name") or die("cannot select DB");

          $query="SELECT Team_Name FROM league_2 ORDER BY Points DESC LIMIT 1";
          $result=mysql_q uery($query);

          if(!mysql_db_qu ery($db_name,$q uery,$link)) die(mysql_error ());

          echo $result;

          ?>

          The error that i am getting with this is: Resource id #3

          Comment

          • mtgriffiths86
            New Member
            • Jan 2008
            • 13

            #6
            I have now tried different approaches to this and have come up with a new error which is

            Resource 5 error

            Does anybody know how to do what i am trying and what these errors are?

            Thanks

            Comment

            • dlite922
              Recognized Expert Top Contributor
              • Dec 2007
              • 1586

              #7
              Originally posted by mtgriffiths86
              I have now tried different approaches to this and have come up with a new error which is

              Resource 5 error

              Does anybody know how to do what i am trying and what these errors are?

              Thanks
              $result is exactly what you see, a resource.

              you must Extract the data from it using one of MySQL builtin function such as mysql_fetch_ass oc($result)

              which gives you an associate array of the data, then you can loop to output it.

              +++++++++++++++ +++++++++++++++ ++

              as far as the leagues, can one team from one league play another?

              Here's what i think should be done from your explanation:

              I would query the DB and SORT them in DESCending order, then with a forloop pair them up in such a manner:
              [PHP]
              $pairedTeams = array();
              for ($i = 0; $i < teamArr; $i++)
              {
              if(!empty($team Arr[$i] && !empty($teamArr[$i+1]))
              {
              $displayStr = $teamArr[$i] . " VS " . $teamArr[$i+1];
              array_push($pai redTeams,$displ ayStr);
              }
              }

              //then display your output
              foreach ($pairedTeams as $pair)
              {
              echo $pair . "\n";
              }


              [/PHP]

              the above should give you a display of:

              1stTeamName VS 2ndBestTeam
              3rdBestTeam VS 4thBestTeam

              If you want the last 2 teams be dropped out, then you have to put a filter on the DB or the for loop above.

              Maybe you query the DB and get the THIRD result when Sorting by score in ASCending order. you take this value and when you do your query you provide the condition WHERE score >= $thirdTeamFromB ottom;

              That should get rid of the bottom two teams with the lowest scores.
              (that is if you don't want them deleted from the database)

              Comment

              Working...