Jump to content

Recommended Posts

I'm creating a league and having everyone be able to create a league, then individual users sign up for specific leagues.  (basically just like yahoo fantasy).  I'm trying to create it all on one database and have never done this before.

 

the 2 main tables we care about are:

- Settings (has inner tables of LeagueID, LeaguePass, Admin_Email, Admin_Pass, etc.)

- Users (has inner tables of LeagueID, Name, Password, Email, Already_Picked, etc.)

 

they both have a LeagueID.  When someone creates a league, I use "Insert INTO" Settings table and create the next LeagueID in order of 1-100.  I also do an "insert into" Users and add a LeagueID which is the same as one for Settings.

 

The trouble I'm having now is how do I create an individual User that goes into the Users->LeagueID?  I want each LeagueID to have all the individual Names in it.  But that's like a table within a table.  The "Insert Into Users" would just create another row of information in the Users.  I want all the rows to go into the Users->LeagueID but you can't use "insert into users where LeagueID = '$LeagueID' " can you?

 

let me try to draw it out how I want it:

Settings   

    LeagueID 1, LeagueName, League Password, GameType, etc.

    LeagueID 2, LeagueName, League Password, GameType, etc.

 

Users

    LeagueID

        1

              Name, Password, Email, etc.

              Name, Password, Email, etc.

        2 

              Name, Password, Email, etc.

              Name, Password, Email, etc.

 

you can see how I want the main table "Users" to have another main sub table called "LeagueID", then I want to have all the individual users in there. 

 

I was thinking when someones logs in it knows what LeagueID they belong to.  Then I could pull all their info based on that LeagueID.  something like

$result = mysql_query("SELECT * FROM Users WHERE LeagueID = '$LeagueID' ");  

 

sorry if this doesnt make sense.  lol

 

Link to comment
https://forums.phpfreaks.com/topic/89907-table-within-a-table/
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.