title: Load Returned mySQL Values Into Form
body: <p>I wonder whether someone may be able to help me please.</p>
  
  <p>I've put together a form and php code (below) that allows an administrator to search for member records from a mysql database using the email address as the search criteria.</p>
  
  <p><strong>HTML Form</strong></p>
  
  <pre><code>   &lt;form name="memberpasswordresetform" id="memberpasswordresetform" method="post" action="search.php"&gt;
      &lt;div class="container"&gt;
          &lt;p align="justify"&gt;Member Details &lt;/p&gt;
          &lt;table width="100%" border="0" cellspacing="0" cellpadding="0"&gt;
              &lt;tr&gt;
                  &lt;td width="26%" height="25"&gt;&lt;strong&gt;Email Address &lt;/strong&gt;&lt;/td&gt;
                  &lt;td width="4%"&gt;&amp;nbsp;&lt;/td&gt;
                  &lt;td width="70%"&gt;&lt;input name="email" type="email" id="email" size="50" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td height="25"&gt;&lt;strong&gt;Confirm Email Address &lt;/strong&gt;&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&lt;input name="conf_email" type="email" id="conf_email" size="50" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td height="25"&gt;&lt;label&gt;
                      &lt;input type="submit" name="Submit" value="search" /&gt;
                      &lt;/label&gt;&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td height="25"&gt;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
              &lt;/tr&gt;
  
              &lt;tr&gt;
                  &lt;td height="25"&gt;&lt;strong&gt;First Name &lt;/strong&gt;&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&lt;input name="fname" type="text" id="fname" size="30" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td height="25"&gt;&lt;strong&gt;Last Name &lt;/strong&gt;&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&lt;input name="lname" type="text" id="lname" size="30" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td height="25"&gt;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td height="25"&gt;&lt;strong&gt;New Password&lt;/strong&gt;&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&lt;input name="newpass" type="password" id="newpass" size="30" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td height="25"&gt;&lt;strong&gt;Confirm New Password &lt;/strong&gt;&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&lt;input name="conf_newpass" type="password" id="conf_newpass" size="30" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td height="25"&gt;&lt;input type="submit" name="save" value="save" /&gt;&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>PHP Script</strong></p>
  
  <pre><code>&lt;?php 
  include("admin/link.php");
  include("admin/opendb.php");
  mysql_select_db ("userdetails"); 
  $term = $_POST['email']; 
  $sql = mysql_query("select forename, surname, email address from userdetails where emailaddress like '%$email%'"); 
  while ($row = mysql_fetch_array($sql)){ 
  echo '&lt;br/&gt; First Name: '.$row['forename']; 
  echo '&lt;br/&gt; Last Name: '.$row['surname']; 
  echo '&lt;br/&gt;&lt;br/&gt;'; 
  } 
  ?&gt;
  </code></pre>
  
  <p>The search functionality works fine, but I can't work out how to populate the forename and surname fields on my form from the records retrieved from my database. I've been looking for, and found examples on how to do this, if I want to simply show the data as a table, but I can't find any that explain how to populate the fields in a form. </p>
  
  <p>I just wondered whether it would be at all possible that someone could provide some guidance please on how I can do this.</p>
  
  <p>Many thanks</p>