title: Populate radio buttons with values from database
body: <p>two Qs in one day...</p>
  
  <p>I'm trying to get the right radio button checked when I pull data from a mysql database to display in an edit form.  Have tried all kinds of code but get the same result each time: the last value is always the one checked.  Mystified.</p>
  
  <p>My code is somewhat complicated by being inside a long html string, hence the construction for reading the php variables.  I have this code at the top of the page:</p>
  
  <pre><code>$row = mysql_fetch_assoc($result, MYSQL_ASSOC);
   if ($row)
   {
   print("&lt;p&gt;$se_id is in the database. You can edit this record.&lt;/p&gt;");
  
   //get variables to set radio buttons in $form
   $type = $row['se_source'];
  $checked[$type] = "checked";
  </code></pre>
  
  <p>etc...  and this code inside the html string:</p>
  
  <pre><code>&lt;li&gt;
      &lt;label for="se_source"&gt;Contributed by:&lt;/label&gt;
            echo ' . $type . '
      &lt;input id="se_source" type="radio" id = "radio" name="se_source"  value="CNFP" checked = ' . $checked["CNFP"] . '&gt;CNFP&lt;/input&gt;
      &lt;input id="se_source" type="radio" id = "radio" name="se_source" value="User" checked = ' . $checked["User"] . '&gt;User&lt;/input&gt;
  </code></pre>
  
  <p></li></p>
  
  <p>The echo statement is for my own sanity -- I know it's not really an echo here.  But even when it says "echo CNFP" it is always the "User" button that is checked.  So I know it is getting the correct value for that variable, but for some reason it defaults to the last value in the list.  I've tried it with "===" as well.  No joy.  Any enlightenment appreciated, thanks so much for taking a look. </p>