title: How can I match a user id value from a form input to records in my database?
body: <p>Hi I'm trying to match a user id value from an input on a form to records in my database.  I'm trying to show a column (itemname) of data in a dropdown select menu that match a userid value from a forms input.  I don't know if I'm properly defining my variables or what im doing wrong but cant see what I'm missing.  Any help is greatly appreciated.  Thanks.</p>
  
  <pre><code>&lt;?php
  
  // Create the connection to the database
  $con=mysqli_connect("xxx","xxx","xxx","xxx");
  
  
  // Check if the connection failed
  if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    die();
  }
  
  
  
    if (isset($_POST['userid']))
  {
      $userid= $_POST['userid'];
  
     $query = "SELECT itemname
          FROM seguin_orders
    WHERE username = '".($userid)."'";
  
      $result = mysqli_query($con,$query);
  }
  ?&gt;
  </code></pre>
  
  <p><strong>FORM WITH DROPDOWN</strong></p>
  
  <pre><code>&lt;form action="xxx" method="post" name="form1"&gt;
  
  
  &lt;select name="xxx"&gt;&lt;option value=""&gt;-- Select One --&lt;/option&gt;
  
  
   &lt;?php 
  
          while ($row = mysqli_fetch_assoc($result)) 
          {
           echo '&lt;option value =" ' . $row['itemname'] . ' "&gt;' . $row['itemname'] . '&lt;/option&gt;';
          }
      ?&gt;
  
  &lt;/select&gt;
  
  
  &lt;input id="input1" name="input1" type="text" /&gt;
  
  &lt;/br&gt;
  
  &lt;input id="userid" name="userid" type="text" value="demo@gmail.com" readonly="readonly"/&gt;
  
  
  
  &lt;button type="submit" value="Submit"&gt;Submit&lt;/button&gt;
  
  
  &lt;/form&gt;
  </code></pre>