Chained Selects - Please help
Posted: Wed Nov 19, 2008 7:08 am
Hi everyone. I'm relatively new to PHP and MySQL, and try as I might, I am yet to find a chained select script that will work for my needs, or I'm just not knowledgable enough to change what I have found to suit my requirements.
Here's what I need.
I'm creating a score submission page for a website I run. At the moment I have got it working where it will email me what is entered in the form here - http://www.ldbsa.co.uk/s_submitscore.php
What I want is to start making it so this data is input into the database I have in the backend. The first step is getting the teams selection box for both the home and away teams to control select boxes below them for player names. As you can see, I currently just let people type in the names, but I'd like to control this using a chained select, where based on the team you select above, the seven boxes below it will each be populated with a player list for that team, for the home team, and the away team.
My database has a table called "Teams" which contains a list of all teams and an auto-increment ID for each team (TeamID, Team) e.g. TeamID 1, Team1; TeamID 2, Team2 etc.
Firstly, I'd like to populate the "HomeTeam" and "AwayTeam" SELECT boxes with the team names from this "Teams" table. This selection will be a the value for variables called $hometeam and $awayteam.
When an user selects a team from the "HomeTeam" SELECT box, the seven player name select boxes below will need to be populated by the Player Names for that team i.e. SELECT Player_Name FROM $hometeam. In other words, the table the child select boxes pulls the data from depends on the selection in the parent.
Eventually what I want is for this form to be processed and update the player win/loss records, and the league table when the form is submitted, but first I'd like to get chained select boxes working.
Is anybody able to assist me on this at all? I feel way out of my depth when trying to figure this out myself.
Here's what I need.
I'm creating a score submission page for a website I run. At the moment I have got it working where it will email me what is entered in the form here - http://www.ldbsa.co.uk/s_submitscore.php
What I want is to start making it so this data is input into the database I have in the backend. The first step is getting the teams selection box for both the home and away teams to control select boxes below them for player names. As you can see, I currently just let people type in the names, but I'd like to control this using a chained select, where based on the team you select above, the seven boxes below it will each be populated with a player list for that team, for the home team, and the away team.
My database has a table called "Teams" which contains a list of all teams and an auto-increment ID for each team (TeamID, Team) e.g. TeamID 1, Team1; TeamID 2, Team2 etc.
Firstly, I'd like to populate the "HomeTeam" and "AwayTeam" SELECT boxes with the team names from this "Teams" table. This selection will be a the value for variables called $hometeam and $awayteam.
When an user selects a team from the "HomeTeam" SELECT box, the seven player name select boxes below will need to be populated by the Player Names for that team i.e. SELECT Player_Name FROM $hometeam. In other words, the table the child select boxes pulls the data from depends on the selection in the parent.
Eventually what I want is for this form to be processed and update the player win/loss records, and the league table when the form is submitted, but first I'd like to get chained select boxes working.
Is anybody able to assist me on this at all? I feel way out of my depth when trying to figure this out myself.