I'm trying to make a select list with options from a MySQL database with PHP remember the last imput. I've learned here how keep the value's in a form after submit with php (second answer) which worked on a select with Yes/No options.
Now i am trying to implement this into the select that has generate options. After i got errors with if-statements I learned here i can use Ternary operators to fix the problem but it does not seem to work. I keep getting errors like --parse error, unexpected '.'--
My code is:
<select name="reeks" onchange="this.form.submit()">
  <option value= "0" style="display:none;" selected="" disabled=""> Reeks </option>
  <?php 
    $sql = "SELECT * FROM reeks";
    $result = (mysql_query($sql));
    while ($row = mysql_fetch_array( $result )){
        $reeks = $row['reeks'];
        echo '<option '. ($_GET['reeks'] == 'ja') ? .'selected="'. $reeks. '" '. ; .' name="reeks">'. $reeks . '</option>';
    }
  ?>
</select>
This is what the code looks like for the Yes/No select
<option <?php if ($_GET['reeks'] == ''. $reeks. '') { ?>selected="'. $reeks. '" <?php }; ?> name="reeks" value="ja">Ja</option>
 
     
    