Option value selected for loop
<p>I am trying to create a <code>selected</code> value of the previous output.
(the user fills in a form , submits, returns to the form) And I want the selected value to be the value the user previously used.</p>

<p>The <code>vraagNummer</code> and <code>answer</code> are given in the url parameter and the dropdown menu of items available in the list are created in a for loop.
Now I got stuck on that part.. How do I create an option selected value if it is created in a for loop?</p>

<p>Usually I would just put in <code>option value = $vraagNummer selected&gt; &lt;?php echo $vraagNummer ?&gt;&lt;/option</code> but in this case that wouldn't work. I suppose?</p>

<p>Anyone knows how to fix this?<br />
Same with the A/B/C/D. How do I put in the selected value of <code>answer</code> into the value previously selected while still keeping the others as an option.<br /><br />
With kind regards,</p>

<pre><code>if(!empty($_GET['vraagnummer'])){
            $vraagNummer = $_GET['vraagnummer'];
            if(!empty($_GET['answer'])){
                $answer = $_GET['answer'];
            }
        }
        echo $vraagNummer;
        echo $answer;
        ?&gt;

        &lt;form id="start" method="post" action="index.php?test=true"&gt;
            &lt;select name="question"&gt;
                &lt;?php 
                for($i= 1; $i &lt; $nRows+1 ; $i++){
                    ?&gt;&lt;option value="&lt;?php echo $i ?&gt;"&gt;Question &lt;?php echo $i?&gt;&lt;/option&gt;
                    &lt;?php
                }
                ?&gt;
            &lt;/select&gt;
            &lt;select name="result"&gt;
                &lt;option value="A"&gt;Answer A&lt;/option&gt;
                &lt;option value="B"&gt;Answer B&lt;/option&gt;
                &lt;option value="C"&gt;Answer C&lt;/option&gt;
                &lt;option value="D"&gt;Answer D&lt;/option&gt;

            &lt;input type="submit" id="submit" value="Submit" /&gt;
        &lt;/form&gt;
</code></pre>