title: Select an option in a dropdown box and display its associated data in php?
body: <ol>
  <li>How to select a supplement and display its associated data such as its description and cost.</li>
  <li>Any help will be appreciated.</li>
  </ol>
  <blockquote>
  <p>PHP:</p>
  </blockquote>
  <pre><code>require('database.php');
  
  $suppID = filter_input(INPUT_POST, 'suppID');
  
  if($suppID==null || $suppID==false){
      $suppID = 'Supplement-1';
  }
  
  $query = 'select * from tblsupplements where Supplement_id= :SupplementID';
  $statement = $db-&gt;prepare($query);
  $statement = bindValue(':SupplementID', $suppID);
  $statement-&gt;execute();
  $supplements = $statement-&gt;fetchAll();
  $statement-&gt;closeCursor();
  </code></pre>
  <blockquote>
  <p>HTML:</p>
  </blockquote>
  <pre><code>&lt;label&gt;Supplement ID:&lt;/label&gt;
  &lt;select name='suppID'&gt;
  &lt;?php foreach ($supplements as $supplement): ?&gt;          
  &lt;option value=&quot;&lt;?php echo $supplement['Supplement_id']; ?&gt;&quot;&gt;
  &lt;?php echo $supplement['Supplement_id']; ?&gt;
  &lt;/option&gt;         
  &lt;?php endforeach; ?&gt;
  &lt;/select&gt;
  
  </code></pre>