title: PHP MySQL edit form select dropdown preselected
body: <p>I have certainly browsed and just haven't been able to get this seemingly easy answer!</p>
  <p>I have a form where I can update records, and I can also edit them by clicking on the edit button I made. When I click to edit them, I obviously want the current settings to be chosen by default. Through $_GET variables, I have prefilled in the text inputs with their correct values from the DB.</p>
  <p>However, I have three dropdown lists, and I am unable to get these to choose their correct value and name.</p>
  <p>My form, for one example, has a dropdown list of all my users coming from a query of:</p>
  <pre><code>SELECT
      users.id AS 'Users ID',
      users.first_name AS 'User First Name',
      users.last_name AS 'User Last Name'
  FROM users
  ORDER BY users.first_name;
  </code></pre>
  <p>With the following it is correctly showing the list of users by name, and the values are being sent as IDs to the DB</p>
  <pre><code>&lt;div class=&quot;form-group&quot;&gt;
      &lt;label&gt;Choose User&lt;/label&gt;&lt;br /&gt;
      &lt;select name=&quot;userid&quot;&gt;
      &lt;?php
          while($usersrow = $usersresult-&gt;fetch_assoc()) {
          //Display Customer Info
          $output = '&lt;option value=&quot;'.$usersrow['User ID'].'&quot;&gt;'.$usersrow['User First Name'].' '.$usersrow['User Last Name'].'&lt;/option&gt;';
  
          //Echo output
          echo $output;                   
          }
      ?&gt;
      &lt;/select&gt;
  &lt;/div&gt;
  </code></pre>
  <p>With this as a setup, does anybody know how I can go to my edit field and have my dropdown preselected where the values remain the users ID? I have tried quite a few different ways including concatening with ternary if, and other $_GET variables of $id (for user id) and $name (for user name), but to no avail.</p>
  <p>Any help is appreciated!</p>
  <h2><strong>EDIT</strong></h2>
  <p>To put it a bit more simply...I am trying to have my dropdown be preselected based off of a $id $_GET variable that matches the value in a dropdown option.</p>
  <p>Thanks</p>