如何在php编辑表单选项中回显db值

时间:2017-01-30 00:14:55

标签: php html mysql

我目前有一个编辑表单,其中所有值都从db回显为每个输入的“值”,然后用户将重新键入并“保存”该值以附加到db。所有回声都有效,但我无法回应选项的数据库值...任何人都知道如何?

&安培;感谢

以下代码:

<fieldset>
    <form id="input-form" method="POST" action="../php/edit-import-record.php">
        Airway Bill Number*:
        <input type=text name=AwbNo size=30 class="input" value="<?php echo $awb ?>" required>
        Client Code:
        <?php               //OPEN DROP DOWN BOX
            include("../login/dbinfo.inc.php");
            $comm=@mysql_connect(localhost,$username,$password);
            $rs=@mysql_select_db($database) or die( "Unable to select database"); 
            $sql=   "SELECT DISTINCT ClientCode, ClientName FROM tbl_client ORDER BY ClientCode";
            $result = mysql_query($sql);
            echo "<select name='ClientCode'>";
            while ($row = mysql_fetch_array($result)) {
                echo "<option  value='" . $row['ClientCode'] ."'>" . $row['ClientName'] ."</option>";
            }
            echo "</select><br>";   //CLOSE DROP DOWN BOX   
        ?><br>
        Vessel Name*:
        <input type=text name=VesselName class=form-control id=inputSuccess size=30 class="input" value="<?php echo $vsl ?>" required>
        Number of Pieces:
        <input type=number name=Pieces size=30 class="input" value="<?php echo $pcs ?>" >
        Total Weight (kg):
        <input type=number name=Weight size=30 class="input" value="<?php echo $wgt ?>" >
        Carrier:
        <input type=text name=Carrier size=30 class="input" value="<?php echo $car ?>" >    
        Sender:
        <input type=text name=Sender size=30 class="input" value="<?php echo $snd ?>" > 
        Status:
        <input type=text name=Status size=30 class="input" value="<?php echo $stt ?>" > 
        Arrival Date:
        <input type=date name=ArrivalDate size=30 class="input" value="<?php echo $ard ?>" >    
        Customs:
        <input type=text name=Customs size=30 class="input" value="<?php $ctm ?>" > 
        <br><small>Fields marked with * are required to be filled in.</small>
        <div class="inputformbutton">
        <button type="reset" class="btn btn-default btn-sm">Reset</button>
        <button type="submit" class="btn btn-primary btn-sm">Create Record</button>  
        </div>
</fieldset> 

0 个答案:

没有答案