title: PHP loop within a loop, option selected?
body: <p>Using PHP I echo out table rows in a loop like this:</p>
  <pre><code>&lt;?php
  /* SQL STUFF */
  
    while ($row = mysql_fetch_array($select_courseelements)) {
     echo &quot;&lt;tr&gt;\n&quot;;
      echo &quot;&lt;td&gt;&quot;.$row['scpe_name'].&quot;&lt;/td&gt;\n&quot;;
      echo &quot;&lt;td&gt;&quot;.$row['scpe_days'].&quot;&lt;/td&gt;\n&quot;;
     echo &quot;&lt;/tr&gt;\n&quot;;
    }
  </code></pre>
  <p>Now I would like to include a <code>&lt;select&gt;</code> element with 5 predefined <code>&lt;option&gt;</code> values inside a <code>&lt;td&gt;</code> running with the loop. The option <code>value</code>s will be 1 to 5. <br /><br />
  There is also a column inside the <code>$row</code> loop that holds a value of 1 to 5 (<code>$row['scpe_grades_status']</code>).</p>
  <p>Each time this value is equal to the one in the <code>&lt;select&gt;</code> I want it to change it to <code>selected='selected'</code>.</p>
  <p>Would this be possible?</p>
  <p>My <code>&lt;select&gt;</code> will look something like this when it's being run in the loop:</p>
  <pre><code>echo &quot;&lt;td&gt;\n&quot;;
  echo &quot;&lt;select id='elements_grade'&gt;\n&quot;;
          echo &quot;&lt;option value='1'&gt;Registrerad&lt;/option&gt;\n&quot;;
          echo &quot;&lt;option value='2'&gt;Ej påbörjad&lt;/option&gt;\n&quot;;
          echo &quot;&lt;option value='3'&gt;Pågående&lt;/option&gt;\n&quot;;
          echo &quot;&lt;option value='4'&gt;Godkänd&lt;/option&gt;\n&quot;;
          echo &quot;&lt;option value='5'&gt;Deltagit&lt;/option&gt;\n&quot;;
          echo &quot;&lt;option value='6'&gt;Ej deltagit&lt;/option&gt;\n&quot;;
  echo &quot;&lt;/select&gt;\n&quot;;
  echo &quot;&lt;/td&gt;\n&quot;;
  </code></pre>