title: Pairing inputted names to previously stored names
body: <p>I currently have this table.</p>
  
  <p><strong>Names</strong></p>
  
  <p>Two fields, ID and Names. Example data would be 1 | Harry.</p>
  
  <p>Now what i am planning on doing is that if someone enters in something like Henry in my form, it will search my database for a result that begins with "H" Then if their are multiple results, it will see if there are any results that are "He" if their isn't it will fallback to the previous result from "H".</p>
  
  <p>The only thing i can think of doing is this,</p>
  
  <pre><code>$inputted_name = "Henry";
  $query = mysql_query("SELECT `name` FROM `names`");
  while($row = mysql_fetch_array($query)){
      $stored_name = $row['name'];
      if($stored_name[0] == $inputted_name[0]){
          if($stored_name[1] == $inputted_name[1]){
              $result = $stored_name;
              break;
          }   else   {
              // continue looking but then return the first result that matched one letter?
          }
      }
  }
  </code></pre>
  
  <p>Now i am sure this can't be the best way to do it. Would it be possible in a query? I'm just really not sure where to look for a sensible answer for this one.</p>