这是整个 php 代码插入查询工作正常,但其余部分仅在 product_is 丢失后才有效。但是,如果我从数据库中输入 product_id 的值,它就可以正常工作。
if(isset($_POST["submit"]))
{
$pname=$_POST["pname"];
$pprice=$_POST["pprice"];
$quant=$_POST["quant"];
$imei_no=$_POST["imei_no"];
$total=$_POST["total"];
$transaction_no=$_POST["transaction_no"];
$sl_sql="insert into sales (pname,pprice,quant,imei_no,total,transaction_no,selling_date) values ('$pname','$pprice','$quant','$imei_no','$total','$transaction_no',NOW())";
$sl_res=mysql_query($sl_sql);
$product_id= $_GET["product_id"];
echo $sc_sql="select * from productlist where product_id='$product_id' ";
$sc_res=mysql_query($sc_sql);die();
while($sc_row=mysql_fetch_object($sc_res))
{
$pid=$sc_row->product_id;
$psold=$sc_row->psold;
$quantity=$sc_row->quantity;
}
$ab=$psold+$quant;
$bc=$quantity-$quant;
$up_sql="update productlist set psold ='$ab', quantity='$bc' where product_id='$pid'";
$up_res=mysql_query($up_sql);
if($up_res)
{
header("location:billing.php");
exit();
}
}
我的下拉列表工作正常。
这是我的 HTML
<form action="" method="post" onsubmit="return validation();" style="float: inherit;">
<table align="center" cellpadding="0" cellspacing="0">
<tr>
<?php
$p_sql="select * from productlist where published=1";
$p_res=mysql_query($p_sql);
?>
<td width="140" height="32"><div align="right"><b>PRODUCT NAME :</b> </div></td>
<td><select name="pname" id="pname" onchange="showprice(this.value);" style=" border-style:groove">
<option value="">Select Your Product</option>
<?php
if($p_res)
{
while($p_row=mysql_fetch_object($p_res))
{
?>
<option value="<?=$p_row->product_id?>"><?=$p_row->pname?></option>
<?php
}
}
?>
</select>
</td>
<td><input type="hidden" name="product_id" id="product_id" value="" /></td>
<td> </td>
<td><div align="right"><b>PRODUCT PRICE :</b></div></td>
<td><div id="price"><input name="pro_price" type="text" readonly="readonly" style=" border-style:groove"/></div></td>
</tr>
<tr>
<td height="32"><div align="right"><b>SELLING PRICE :</b></div></td>
<td><input name="pprice" id="pprice" type="text" value="" style=" border-style:groove"/></td>
</tr>
<tr>
<td width="119" height="32"><div align="right"><b>QUANTITY:</b> </div></td>
<td width="184"><input name="quant" id="quant" type="text" onkeyup="multi()" onkeypress="return checkIt(event)" style=" border-style:groove"/></td>
</tr>
<tr>
<td height="32"><div align="right"><b>TRANSCATION NO. :</b></div></td>
<td><input name="transaction_no" id="transaction_no" type="text" readonly value="<?php echo $_SESSION["transaction"]; ?>" style=" border-style:groove"/>
</td>
</tr>
<tr>
<td><div align="right"><b>IMEI NUMBER :</b> </div></td>
<td><input name="imei_no" type="text" id="imei_no" maxlength="14" onkeydown="is_num();" style=" border-style:groove"/></td>
</tr>
<tr>
<td><div align="right"><b>Sub Total :</b> </div></td>
<td><input name="total" id="total" type="text" readonly="readonly" style=" border-style:groove"/></td>
<td> </td>
<td> </td>
<td> </td>
<td style="float:right;"><input name="submit" type="submit" value="" style="height: 90px; width: 110px; cursor:pointer; background-image:url(images/cart.png); border:none;"id="xx" /></td>
</tr>
</table>
</form>