I have multiple dropdown menus. When the user clicks submit button. The isset function in the if clause is triggerd and the following code gets executed
if(isset($_POST["submit"]))
{
$player_id = $_REQUEST['players'];
var_dump ($player_id);
for($i=0; $i < sizeof($player_id); $i++) //query database with different player_id each time
{
foreach ($player_id as $id){
$query = 'SELECT `name` FROM `player_info`
WHERE `player_id` = '.$id;
$return_names = mysql_query($query) or die(mysql_error());
}
while($row = mysql_fetch_array($return_names))
{
$selected[] = $row['name'];
}
var_dump($selected);
}
}
What the above code should do is return the names, of the players, the user selected. However when I open it I get this:
Notice the $player_id array which I use in the 1st var_dump holds the different player_id values.
However when I do a var_dump on the second array $selected the array contains only the values "Burger"
I suspect the problem is in the foreach loop and the way I query the database. If someone could point me in the right direction it would be greatly appreciated. Thanks in advance.