I want to keep selected values after form submission, as suggested here by @ignacio-vazquez-abrams. I tried this:
<form action="" method="get">
    ...
    foreach ($file_array as $location)
        $options .= '<option name="' . $location . (($_GET['name'] == $location) ? 'selected="true"' : '') . '" value="' . $location . '">' . $location .'</option>';
    $select = '<select id="location" name="location">' . $options . '</select>';
    echo $select;
    ...
</form>
but I got a notice:
Notice: Undefined index: name in ...
UPDATE
Than I tried this (as was suggested in comments and I how is recommended here):
$options .= '<option name="' . $location . (!isset($_GET['selected']) ? 'selected="selected"' : '') . '" value="' . $location . '">' . $location .'</option>';
with no errors, but the expected result still has not been produced - selected values after form submission are not retained.
How to achieve this?
 
     
     
    