chiefrokka Posted February 7, 2008 Share Posted February 7, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/89907-table-within-a-table/ Share on other sites More sharing options...
revraz Posted February 7, 2008 Share Posted February 7, 2008 3rd table UserID | LeagueID Quote Link to comment https://forums.phpfreaks.com/topic/89907-table-within-a-table/#findComment-460845 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.