title: how to find the match value and display value automatically on dropdown
body: <p>Just want to know how to find the match value on the dropdown list and display the value as current selected for update. </p>
  
  <p>this is my table query and displayed on page with update link beside each row. All update link is working and the value displayed on hidden textbox. My problem is just on one column $trandescription, this will be post on dropdown.</p>
  
  <p>this is my display table.</p>
  
  <pre><code>  while($row = mysql_fetch_array($query)) 
    {
    echo "
    &lt;tr&gt;
    &lt;td style='border:1px solid; color:gray' width='145px' align='center'&gt;".$row['patientid']."&lt;/td&gt;
    &lt;td style='border:1px solid; color:gray' width='145px' align='center'&gt;".$row['trandate']."&lt;/td&gt;
    &lt;td style='border:1px solid; color:gray' width='600px'&gt;".$row['trandescription']."&lt;/td&gt;
    &lt;td style='border:1px solid; color:gray' width='90px' align='center'&gt;".$row['tranquantity']."&lt;/td&gt;
    &lt;td style='border:1px solid; color:gray' width='90px' align='right'&gt;".number_format($row['tranunitprice'],2)."&lt;/td&gt;
    &lt;td style='border:1px solid; color:gray' width='150px' align='right'&gt;".number_format($row['tranamount'],2)."&lt;/td&gt;
    &lt;td style='border:1px solid; color:gray'&gt;&lt;a href='updatebillindex.php?update=$row[id]'&gt;update&lt;/a&gt;&lt;/td&gt;
    &lt;td style='border:1px solid; color:gray'&gt;&lt;button class='btn btn-default btn-sm';&gt;&lt;a href='updatebillindex.php?update=$row[0]'&gt;edit
    &lt;span class='glyphicon glyphicon-trash'&gt;&lt;/span&gt;&lt;/a&gt;&lt;/button&gt;&lt;/td&gt;
    &lt;/tr&gt; ";
  </code></pre>
  
  <p>this is my update page</p>
  
  <pre><code>  &lt;?php
          if (isset($_GET['update'])) 
          {
  
          $id = $_GET['update'];
  
          $query = mysql_query("SELECT * FROM transaction where id = '$id'") or die ("could not search");
          $count = mysql_num_rows($query);    
  
          while ($rows = mysql_fetch_array($query)) {
  
          $id = $rows['id'];
          $tranid = $rows['tranid'];
          $trandate = $rows['trandate'];
          $patientid = $rows['patientid'];
          $transactiontype = $rows['transactiontype'];
          $trandescription = $rows['trandescription'];
          $tranquantity = $rows['tranquantity'];
          $tranunitprice = $rows['tranunitprice'];
          $tranamount =$rows['tranamount'];
          $gettrandescription = $rows['trandescription'];
  
          }
  
  }
  
          ?&gt;
  
          &lt;form action="billindex.php" method="POST"&gt;
  
          &lt;input type="hidden" name="id" value="&lt;?php echo "$id"; ?&gt;"&gt;
          &lt;input type="hidden" name="tranid" value="&lt;?php echo "$tranid"; ?&gt;"&gt;
          &lt;input type="hidden" name="patientid" value="&lt;?php echo "$patientid"; ?&gt;"&gt;
          &lt;input type="hidden" name="trandate" value="&lt;?php echo "$trandate"; ?&gt;"&gt;
          &lt;input type="hidden" name="transactiontype" value="&lt;?php echo "$transactiontype"; ?&gt;"&gt;
          &lt;input type="text" name="trandescription" value="&lt;?php echo "$trandescription"; ?&gt;"&gt;
          &lt;input type="hidden" name="tranquanity" value="&lt;?php echo "$tranquantity"; ?&gt;"&gt;
          &lt;input type="hidden" name="tranunitprice" value="&lt;?php echo "$tranunitprice"; ?&gt;"&gt;
          &lt;input type="hidden" name="tranamount" value="&lt;?php echo "$tranamount"; ?&gt;"&gt;
          &lt;input type="submit" name="update" value="Update"&gt;
  
          &lt;/form&gt;
  
          &lt;?php
          echo "$trandescription"; // find the match value on dropdown list and display this value.
          ?&gt;
  </code></pre>
  
  <p>this is my dropdown list on the update page</p>
  
  <pre><code>   &lt;div class="panel panel-default"&gt;
          &lt;div class="panel-heading" role="tab" id="headingTwo"&gt;
          &lt;h4 class="panel-title"&gt;
          &lt;a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo"&gt;
          Medicine
          &lt;/a&gt;
          &lt;/h4&gt;
          &lt;/div&gt;
          &lt;div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo"&gt;
          &lt;div class="panel-body"&gt;
          &lt;form action="transaction.php" method="POST"&gt;
          &lt;div class="col-md-6"&gt;
          &lt;div class="panel panel-info"&gt;
          &lt;div class="panel-heading"&gt;&lt;h7&gt;Medicine Type : &lt;/h7&gt;&lt;/div&gt;
          &lt;div class="panel-body"&gt;
          &lt;select name="selectmedicine" class="form-control col-sm-4" id="medicinename"&gt;
          &lt;option id="0" style="width:100px"&gt;&lt;/option&gt;
          &lt;?php
  
          $medicine = mysql_query("SELECT * FROM medicine");
          while ($row = mysql_fetch_array($medicine)) {
          echo '&lt;option id="' . $row['medicinename']  . '"';
          echo ' value="' . $row['medicineid'] . '"';
          if($row['medicineid'] == $row['medicinename']) {
          echo ' selected="selected"'; 
          }
          echo '&gt;';
          echo $row['medicinename'];
          echo '&lt;/option&gt;';               
          }
          ?&gt;
          &lt;/select&gt;
          &lt;/div&gt;
          &lt;/div&gt;
          &lt;/div&gt;          
  </code></pre>