Welcome to PHPBuilder! When posting PHP code, please use the board's [noparse]
..
[/noparse] bbcode tags as they make your code much easier to read and analyze.
Martsparts wrote:I'm trying to copy data from one table into another.
Don't. 🙂
Why duplicate data? What happens when Mr. Rooney changes his name or transfers teams? You've got to search all over your database for records to update... or worse, miss some records and have data get out of sync.
Before you get any further, you should stop and read some articles on database normalization. For example, in your example scenario above, I would have three tables - players, teams, team_players (or team_members or something of that nature).
players - contains all the info about the player (including a PRIMARY key, such as an AUTO_INCREMENT column).
team - contains all the info about a team (similar to players above)
team_players - table with two columns, both foreign keys; one for a row in players and one for a row in team.
Example data:
players (id, player_name, player_hometown):
(123, 'Rooney', 'Croxteth, Liverpool, England')
teams (id, team_name, team_manager):
(456, 'Manchester United', 'Alex Ferguson')
team_players (player_id, team_id):
(123, 456)
EDIT: Woops.. looks like leatherback types faster. :p