Jump to content

Populating tables with random data


joebudden

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.