joebudden Posted January 21, 2007 Share Posted January 21, 2007 Hi guys,right, iv got a table of around 100 players.for the game the user picks 6 players for their team and inserts the player's id into the teams table.when the user submits their team i want to populate the teams table with 7 other random teams.However, I have implemented code to do this using this query[code]"SELECT id FROM player ORDER BY RAND() LIMIT 6"[/code]the problem is that players can be added to a team more than once.Is there a way to make the players added unique?so that one player can only be in one team, rather than 1 player appearing in more than one team???any ideas please?? Link to comment https://forums.phpfreaks.com/topic/35133-populating-tables-with-random-data/ Share on other sites More sharing options...
discostudio Posted January 21, 2007 Share Posted January 21, 2007 If you make a say "player id" field in the DB "UNIQUE", the moment you try and add that player's ID again you will get a MySQL error message. Link to comment https://forums.phpfreaks.com/topic/35133-populating-tables-with-random-data/#findComment-165822 Share on other sites More sharing options...
joebudden Posted January 21, 2007 Author Share Posted January 21, 2007 hmm yes iv thought about that, but in the teams table the player id will not be unique as it may be used in someone elses game. this would only work if i created a new table for each user that plays the game..is there not something i can add to that query Link to comment https://forums.phpfreaks.com/topic/35133-populating-tables-with-random-data/#findComment-165825 Share on other sites More sharing options...
joebudden Posted January 21, 2007 Author Share Posted January 21, 2007 anyone got a solution please??? Link to comment https://forums.phpfreaks.com/topic/35133-populating-tables-with-random-data/#findComment-165871 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.