Javascript Solution One Page
After choosing your home player, you need to trigger an event to exclude the player from the second drop-down list. You can do this using JavaScript, for example.
In your options, add an identifier, for example:
<select id='homeTeamPlayer'> <select id='awayTeamPlayer'>
In the first <select> add the onchange javascript method as follows:
<select onchange="excludePlayer()">
This method should disable the option in the second drop-down list:
function excludePlayer() { var homeTeamPlayerId= document.getElementById("homeTeamPlayer").value // Get all options within <select id='homeTeamPlayer'>...</select> var op = document.getElementById("awayTeamPlayer").getElementsByTagName("option"); for (var i = 0; i < op.length; i++) { // lowercase comparison for case-insensitivity (op[i].value == homeTeamPlayerId) ? op[i].disabled = true : op[i].disabled = false ; } }
(I copied the disabled code here: How to disable <option> in <select> based on its value in JavaScript? )
You must also implement this for a second fall.
<html> <head> <script> function excludePlayer() { var homeTeamPlayerId= document.getElementById("homeTeamPlayer").value </script> </head> <body> <select id='homeTeamPlayer' onchange="excludePlayer()"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> <select id='awayTeamPlayer'> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> </html>
Two-Page SQL Solution
The first time you have one drop-down list to select a home team player. The generated HTML should look like this:
<form method="post" action="page2.php"> <select data-placeholder='Spieler auswƤhlen...' class='chosen-select' style='width:220px;' multiple tabindex='4' name='homespieler' required> <option ...> ... </option> <option ...> ... </option> </select> <input type=submit /> </form>
On your second page, you can now get the value of the selected home player as follows: $POST_['homespieler']
You can do this in your request as follows:
SELECT * FROM $player_table_2016 WHERE active = 1 AND ID != $POST_['homespieler'] ORDER by name ASC