请帮我。我在用 PHP 中的 echo 显示 html 中的值时遇到问题
这是我的编码。
<input type="text" value ="123" id="addorderquantity[<?php echo $count - 1; ?>]" name="quantity[<?php echo $count - 1; ?>]" onChange="addordercalculate(<?php echo $count - 1; ?>)">
在输入框中,该值始终显示为“0”,即使我已经将其设置为“123”
但是如果我将id写入“ addorderquantity[<?php echo $count; ?>]
”(不带负1)该值可以正常工作。
这是所有的代码
<?php
$queryorder = "select * from orderitem,product where (orderitem.productid = product.productid) and orderitem.orderid = '$orderid' and orderitem.actype != 'D'";
$resultorder = mysql_query($queryorder);
$count = 1;
while ($order = mysql_fetch_array($resultorder)){
?>
<tr>
<td><?php echo $count; ?></td>
<td>
<select id="addordercategory[<?php echo ($count - 1); ?>]" name="category[<?php echo ($count - 1); ?>]" onChange="loadproduct(<?php echo ($count - 1); ?>)">
<option></option>
<?php
for($i=0; $i<count($datacategorys)-1; $i++){
$data1 = explode ("||",$datacategorys[$i]);
if ($order['category'] == $data1[0]){
echo "<option value='$data1[0]' selected>$data1[1]</option>";
}
else{
echo "<option value='$data1[0]'>$data1[1]</option>";
}
}
?>
</select>
</td>
<td>
<select id="addorderproduct[<?php echo ($count - 1); ?>]" name="product[<?php echo ($count - 1); ?>]" onChange="loadpriceweight(<?php echo ($count - 1); ?>)">
<?php
$queryproduct = "select * from product where category = '".$order['category']."' and actype != 'D'";
$resultproduct = mysql_query($queryproduct);
while ($product = mysql_fetch_array($resultproduct)){
if ($order['productid'] == $product['productid']){
echo "<option value='".$product['productid']."' selected='selected'>".$product['name']."</option>";
}
else{
echo "<option value='".$product['productid']."'>".$product['name']."</option>";
}
}
?>
</select>
<script type="text/javascript">loadpriceweight(<?php echo ($count - 1);?>);</script>
</td>
<td>
<input type="hidden" id="addorderprice[<?php echo ($count - 1); ?>]" name="price[<?php echo ($count - 1); ?>]" value="0">
<input type="text" id="addorderdisprice[<?php echo ($count - 1); ?>]" disabled="disabled" value="">
</td>
<td>
<input type="hidden" id="addorderweight[<?php echo ($count - 1); ?>]" name="weight[<?php echo ($count - 1); ?>]" value="0">
<input type="text" id="addorderdisweight[<?php echo ($count - 1); ?>]" disabled="disabled" value="0">
</td>
<td><input type="text" value ="123" id="addorderquantity[<?php echo ($count - 1); ?>]" name="quantity[<?php echo ($count - 1); ?>]" onChange="addordercalculate(<?php echo ($count - 1); ?>)"></td>
<td><input type="text" id="addorderdiscount[<?php echo ($count - 1); ?>]" name="discount[<?php echo ($count - 1); ?>]" value="0" onChange="addordercalculate(<?php echo ($count - 1); ?>)"></td>
<td><input type="text" id="addorderdistotprice[<?php echo ($count - 1); ?>]" disabled="disabled" value="0"><input type="hidden" id="addordertotprice[<?php echo ($count - 1); ?>]" name="totprice[<?php echo ($count - 1); ?>]" value="0"></td>
<td><input type="text" id="addorderdistotweight[<?php echo ($count - 1); ?>]" disabled="disabled" value="0"><input type="hidden" id="addordertotweight[<?php echo ($count - 1); ?>]" name="totweight[<?php echo ($count - 1); ?>]" value="0"></td>
<td><input type="button" id="addorderhapus[<?php echo ($count - 1); ?>]" value="hapus" onClick="addorderhapus(<?php echo ($count - 1); ?>)"></td>
</tr>
<script type="text/javascript">addordercount = <?php echo $count;?>;</script>
<?php
$count++;
}
?>
请帮助我,非常感谢。