...

View Full Version : Accessing data from tables, etc...



dniwebdesign
04-12-2004, 01:41 AM
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.

Nightfire
04-12-2004, 02:05 AM
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?

dniwebdesign
04-12-2004, 02:22 AM
I Two tables (show in red)
http://www.nsjhl.com/hspic/twotables.JPG

Inside hockeystats_players I have something like below:
http://www.nsjhl.com/hspic/players.JPG
and inside hockeystats_teams I have the below..
http://www.nsjhl.com/hspic/teams.JPG

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?

Nightfire
04-12-2004, 02:43 AM
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.

dniwebdesign
04-12-2004, 02:47 AM
wouldn't that be the same, only with numbers instead of abbreviations.

Nightfire
04-12-2004, 07:09 AM
Yeah, but with numbers you then don't have to have the user input an abreviation of the team name



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum