【发布时间】:2015-04-12 18:37:05
【问题描述】:
我有以下数据要从数据库显示,这是不行的。
<table class="table-style-one" width="90%" border="0" cellspacing="1" cellpadding="1" style="margin:0 auto;">
<thead style="color:black;">
<th style="text-align:center;">S.N</th>
<th style="text-align:center;">PO REFERENCE</th>
<th style="text-align:center;"><strong>ITEM NAME</strong></th>
<th style="text-align:center;"><strong>UNIT</strong></th>
<th style="text-align:center;"><strong>QUANTITY IN STOCK</strong></th>
<th style="text-align:center;"><strong>FROM THIS</strong></th>
<th style="text-align:center;"><strong>THIS QUANTITY</strong></th>
</thead>
<tbody>
<?php
$i=1;
while($rs_rows=mysql_fetch_array($result_of_SQL_GET_POREF_FOR_ITEM))
{
?>
<tr <?=$bg?>>
<td align="center" style="padding-top:5px;">
<?=$i?>
</td>
<td width="54%" align="center" style="padding-top:5px;"> <font color="#000000"><?=$rs_rows['po_reference_name'];?>
</font> </td>
<td width="54%" align="center" style="padding-top:5px;"> <font color="#000000"><?=$rs_rows['item_name'];?>
</font> </td>
<td width="54%" align="center" style="padding-top:5px;"> <font color="#000000"><?=$rs_rows['unit_name'];?>
</font> </td>
<td width="54%" align="center" style="padding-top:5px;"> <font color="#000000"><?=$rs_rows['Total_Quantity'];?></font></td>
<td width="54%" align="center" style="padding-top:5px;"> <font color="#000000">
<input type="checkbox" name="check_list[]" value="<?=$rs_rows['po_refrence_id'];?>">
</font></td>
<td width="54%" align="center" style="padding-top:5px;">
<font color="#000000"><input type="text" name="txt[<?=$rs_rows['po_refrence_id'];?>]"></font>
</td>
</tr>
<?php
$i++;
}
?>
<tr class="text">
<td colspan="7"><div align="center">
<p>
<input type="hidden" name="req" value="<?=$req?>">
<input type="submit" name="save" value="Save" class="submit" tabindex="3" >
<input type="reset" name="Reset" value="Cancel" class="submit" tabindex="4">
<?php
if(isset($_GET[msg])) echo "<font color=red>".$_GET[msg]."</font>";
// if(isset($messsag)) echo $messsag;
?>
</p>
</div></td>
</tr>
</tbody></table>
这是用户向用户发出数量的形式,假设请求的数量是 10,那么管理员可以从一个 po 参考中发出这 10 个项目,或者从 po-laptop-hp-1 中发出一些数量,并且一些来自 po-dell-hp-1。我想验证在提交之前应该验证用户在文本字段中为每一行输入的数量是否少于库存数量。所有文本字段数量之和不超过请求数量。还有……
我已经编写了这段代码,但没有按预期工作,
if(isset($_POST['save']))
{
if ($_GET[add]==0)
{
if($_GET['req']=="") $abc= $_POST['req'];
if($_POST['req']=="") $abc= $_GET['req'];
echo $abc;
$quantity_issued = $qty;
foreach($_POST['check_list'] as $selected){
foreach ( $_POST['txt'] as $key => $value )
{
echo 'Textbox #'.htmlentities($key).' has this value: ';
echo htmlentities($value);
}
$SQL_Query_Get_Item_Quantity = mysql_query("SELECT * FROM stock WHERE po_refrence_id = '".$selected."'");
if($SQL_Query_Get_Item_Quantity === FALSE){
die(mysql_error());
}
else{
$result_SQL_Query_Get_Item_Quantity = mysql_fetch_assoc($SQL_Query_Get_Item_Quantity);
if($quantity_issued > $result_SQL_Query_Get_Item_Quantity['quantity'] && $result_SQL_Query_Get_Item_Quantity['quantity'] != 0){
echo 'quantiy you want to issued is more than the quantity that this po refrence holds';
}
else{
//echo $result_SQL_Query_Get_Item_Quantity['quantity']."</br>";
echo 'quantiy you want to issued is less than the quantity that this po refrence holds';
}
}
}
更新:
我已经完成了大部分工作,剩下的就是我必须在按下保存按钮之前验证,是否在文本框中输入的数量小于行/po 引用的数量。
【问题讨论】:
标签: javascript php jquery mysql validation