如何显示/获取数据库中的第2列值不显示在选项中?

I have table query which is displayed thru select option. The column 1 value is displayed on it. When I select the row 1 value from column 1, I also want the value on column 2 automatically displayed, how would I code that?

Example : medicinename(column1) = medicineprice(column2)

The medicinename is in select option. The medicineprice is not. Just want to display automatically the price every time I select the medicinename.

<div class="col-md-3"><label><h5>Medicine Name : </h5>
<select name="selectmedicine" class="form-control col-sm-4" id="medicinename" style="width:200px">
    <option id="0" style="width:100px"> Select here...</option>
        <?php
            require_once 'config.php';
            $medicine = mysql_query("SELECT * FROM medicine");
            while ($displaymedicine = mysql_fetch_array($medicine)) {
            $medicineid = $displaymedicine['id'];
            $medicinename = $displaymedicine['medicinename'];
            $medicineprice = $displaymedicine['medicineprice'];
        ?>

        <option id="<?php echo $displaymedicine['medicineid']; ?>"><?php if($displaymedicine ['medicineid'] == $displaymedicine ['medicinename']) echo 'selected="selected"'; ?><?php echo $displaymedicine ['medicinename'] ?></option>            

        <?php 
        }
        ?>
</select>

Do you mean you want to be returned the price of the medicine to your PHP script when you select the name of the medicine? In which case you need to add a value="" attribute to the <option tag. It is the contents of value="" that is returned to the script i.e. if this option was selected from your <select name="selectmedicine">

<option value="999"...>Penicillin</option>

Then PHP would receive $_POST['selectmedicine'] which would contain 999

<div class="col-md-3"><label><h5>Medicine Name : </h5>
<select name="selectmedicine" class="form-control col-sm-4" id="medicinename" style="width:200px">
    <option id="0" style="width:100px"> Select here...</option>
<?php

    require_once 'config.php';

    $medicine = mysql_query("SELECT * FROM medicine");
    while ($row = mysql_fetch_array($medicine)) {
        echo '<option id="' . $row['medicineid']  . '"';
        echo ' value="' . $row['medicineprice'] . '"';
        if($row['medicineid'] == $row['medicinename']) {
           echo ' selected="selected"'; 
        }
        echo '>';
        echo $row['medicinename'];
        echo '</option>'            
    }
?>
</select>

Of course a better solution would be to put the unique ID of the medicine table into the value="" attribute. Then when the form is posted to your PHP script you read your database for that one row and you have all the data related to that medicine available to the script.

So that would be

<div class="col-md-3"><label><h5>Medicine Name : </h5>

<select name="selectmedicine" class="form-control col-sm-4" id="medicinename" style="width:200px">

    <option id="0" style="width:100px"> Select here...</option>


<?php

    require_once 'config.php';

    $medicine = mysql_query("SELECT * FROM medicine");
    while ($row = mysql_fetch_array($medicine)) {
        echo '<option id="' . $row['medicineid']  . '"';

> changed code line
        echo ' value="' . $row['id'] . '"';
> changed code line

        if($row['medicineid'] == $row['medicinename']) {
           echo ' selected="selected"'; 
        }
        echo '>';
        echo $row['medicinename'];
        echo '</option>'            
    }
?>