Jump to content

Using data in multiple tables (in 1 database)


Lucky2710

Recommended Posts

I have 4 tables "a users table" "a teams table" "a games table" and "a picks table"

 

 

Tables are set up like this...

 

Games        Teams        Picks              Users

- ID            - ID          - ID                - id

- Week        - Team      - User_ID        - full_name

- Away                          - Game_ID    - user_name

- Home                          - Pick            - password

 

 

My issue is getting the data from the multiple tables at one time.

Like i need to pull from teams the team name into games  (away and home) each team has a different id and in the games table in the way spot is that teams id. so how do u pull the team name depending on what is in the away field.

 

If i can figure that out i can figure the rest out on my own. but i dont have a clue how to do that major starting place.

 

My plan is to use php to echo the data onto the page.

 

Thanks for any help i can get!

 

Server version is 5.1.42

Client Version is 5.1.37

Apache/2.0.52  (Red Hat)

Link to comment
Share on other sites

$result1 = mysql_query("SELECT  CollegeFootballGames.ID, CollegeFootballGames.Week,  CollegeFootballGames.Away, CollegeFootballGames.Home, CollegeFootballTeams.Team
FROM CollegeFootballGames INNER JOIN CollegeFootballTeams
ON CollegeFootballGames.Away = CollegeFootballTeams.ID || CollegeFootballGames.Home=CollegeFootballTeams.ID");
while ($row = mysql_fetch_object($result1)) {
    $GameID[] = $row->ID;
    	$Teams[] = $row->Team;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.