HTML下拉列表& php动态创建

时间:2011-07-29 23:05:49

标签: php html

我无法创建选项并将其与表单一起发布。

这是我现在拥有的。 db连接器已经在工作。

 <select class="form-dropdown validate[required]" style="width:150px" id="input_5"       name="account">
 <?php
 while($row = mysql_fetch_row($result)){
 $bid =$row[0];
$account = $row[1];
echo '<option value="'.$bid.'>"'.$account.'"</option>"';

}

?>
</select>

它不会发布到:

   function calculateBilling(){ 

        $date = date('mdY');
        $bid = mysql_real_escape_string($_POST['bid']);
        $account = mysql_real_escape_string($_POST['account']);
        $timein = mysql_real_escape_string($_POST['timein']);
        $desc = mysql_real_escape_string($_POST['desc']);
        $hrs2calc1 = mysql_real_escape_string($_POST['hrly']);
        $hrs2calc2 = mysql_real_escape_string($_POST['rhrly']);


        $query = 'SELECT bid, account, hrly, rhrly, bal FROM billing WHERE bid="'.$bid.'"';

        echo $query;
        $result = mysql_query($query);
        while($row = mysql_fetch_row($result)){
                $accounttobebilled = $row[1];
                $first = $row[2];
                $second = $row[3];
                $curbal = $row[4];
            }

            $sub1 = $hrly * $hrs2calc1;
            $sub2 = $rhrly * $hrs2calc2;
            $subtotal = $sub1 + $sub2;

            $total = $curbal + $subtotal;

            mysql_query("UPDATE billing SET bal = '" . $total . "' WHERE bid ='" . $bid . "'");


        // Update Billing Log for this customer

        mysql_query("INSERT INTO billingLog (bid, date, hrsOnsite, hrsRemote, timein, descript, total) VALUES ('$bid', '$date', '$hrs2calc1', '$hrs2calc2', '$timein', '$desc', '$subtotal')");

   }

我的问题是结算ID(出价)没有与其所包含的表单一起发布。如果我在发布之前在html页面上回显$ bid,那就很好。它只是不发布到上面的功能。 bid是一个整数。

谢谢!

2 个答案:

答案 0 :(得分:1)

你的报价很古怪:

echo '<option value="'.$bid.'>"'.$account.'"</option>"';

会输出:<option value="123>"My Account Name"</option>"

试试这个:

echo '<option value="'.$bid.'">'.$account.'</option>';

应输出:<option value="123">My Account Name</option>

答案 1 :(得分:0)

我对该项目的名称未出价。固定!