title: How would I go about using a drop down list using a select query to update text fields based on selected option (php/mysql)
body: <p>Example:</p>
  <pre><code>echo '&lt;select&gt;';
  $mysqli = new mysqli( &quot;localhost&quot;, &quot;root&quot;, &quot;user&quot;, &quot;db&quot; );
  $con = $mysqli;
  if( $mysqli-&gt;connect_errno ) {
  die(&quot;Failed to connect to MySQL: (&quot; . $mysqli-&gt;connect_errno . &quot;) &quot; . $mysqli-&gt;connect_error);    
  }
  $username = $_SESSION['user'];
  $selectStatement = &quot;SELECT id FROM purchase_order WHERE username = ?&quot;;  
  $statement1 = $mysqli-&gt;prepare( $selectStatement );
  $statement1-&gt;bind_param( &quot;s&quot;, $username );
  $statement1-&gt;execute();
  $statement1-&gt;bind_result( $id );
  while( $statement1-&gt;fetch() ) {                         
  echo '&lt;option value=&quot;' . $id . '&quot;&gt;' . $id . '&lt;/option&gt;';
  }
  echo '&lt;/select&gt;';
  </code></pre>
  <p>Now lets say I have text fields for Quantity, Description, Amount, Subtotal, Tax, Total and once I select ID 2 in the drop down list, I'd like for the values in the text fields to show the data of the 2nd ID in my database.</p>
  <pre><code>$username = $_SESSION['user'];
  $selectStatement = &quot;SELECT * FROM purchase_order WHERE username = ?&quot;;   
  $statement1 = $mysqli-&gt;prepare( $selectStatement );
  $statement1-&gt;bind_param( &quot;s&quot;, $username );
  $statement1-&gt;execute();
  $statement1-&gt;bind_result( $id );
  $statement1-&gt;fetch();
  
  echo '&lt;input type=&quot;text&quot; value=&quot;' . $quantity . '&quot; id=&quot;quantity&quot; name=&quot;quantity&quot; readonly&gt;';
  
  echo '&lt;input type=&quot;text&quot; value=&quot;' . $description . '&quot; id=&quot;description&quot; name=&quot;description&quot; readonly&gt;';
  
  echo '&lt;input type=&quot;text&quot; value=&quot;' . $amount . '&quot; id=&quot;amount&quot; name=&quot;amount&quot; readonly&gt;';
  
  etc.
  </code></pre>
  <p>I assume its a $_GET or $_POST solution. I'm not sure how to approach this. Please help.</p>