Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder dniwebdesign's Avatar
    Join Date
    Dec 2003
    Location
    Carrot River, Saskatchewan
    Posts
    845
    Thanks
    15
    Thanked 10 Times in 10 Posts

    Accessing data from tables, etc...

    Well, here is my problem...
    I have two tables: hockeystats_players & hockeystats_teams

    hockeystats_players has a few coloums for the players stats as well as a field called "team", which signifies which team they are on.

    hockeystats_teams has a few coloumn for the team stats as well as a field called "team" which gives the name of the team and a "team_id" which is the shorter version of the team.

    For example:
    The Team = Tri-Town Thunder
    Team ID = thunder

    The players table uses the shorter ID however when I display stats as well as other things that uses the shorter name I would like to display the real team name "Tri-Town Thunder" instead of just "thunder".

    Another problem is that this may be used for other hockey leagues so we do not know the team name, or the id used. So it will have to read from the database.

    What do I have to do to get that to do that? I'm really stuck on this problem.
    Dawson Irvine
    CEO - DNI Web Design
    http://www.dniwebdesign.com

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Ok, I'm really confused. You have a hockey team database, yet you don't know the teams in the league, and have no idea who they'll be playing?
    For one that doesn't sound like it's organised right.

    Another thing is, I don't understand your problem. Team id should be a number, team name should say the team's name. If you got a field called team which shows the whole team name and the team_id which shows an abbreviation, then why not show the field team?

  • #3
    Regular Coder dniwebdesign's Avatar
    Join Date
    Dec 2003
    Location
    Carrot River, Saskatchewan
    Posts
    845
    Thanks
    15
    Thanked 10 Times in 10 Posts
    I Two tables (show in red)


    Inside hockeystats_players I have something like below:

    and inside hockeystats_teams I have the below..


    Now, if I want to show the list of player I do not want the team they are on to just show "thunder" I would like it to show "Tri-Town Thunder".

    As far as the comment as I don't know the teams I am meaning that this may be used for other leagues which have different teams and different team names so I cannot just hardcode an 'if' statement into my code. See what I'm saying now?
    Dawson Irvine
    CEO - DNI Web Design
    http://www.dniwebdesign.com

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Have the team_id as a number. Have the team in the players stats as a number. Then do a select query
    SELECT team FROM hockeystats_teams WHERE team_id='$theteamidvariable'

    That will show the full team name instead of just a part of it.

  • #5
    Regular Coder dniwebdesign's Avatar
    Join Date
    Dec 2003
    Location
    Carrot River, Saskatchewan
    Posts
    845
    Thanks
    15
    Thanked 10 Times in 10 Posts
    wouldn't that be the same, only with numbers instead of abbreviations.
    Dawson Irvine
    CEO - DNI Web Design
    http://www.dniwebdesign.com

  • #6
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Yeah, but with numbers you then don't have to have the user input an abreviation of the team name


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •