我正在制作条形码系统,我的验证只取决于应该验证的一行,取决于我的项目的请求数量。它在一个项目中工作,但是当我添加另一个项目。它只会以错误的方式进行验证。例如:请求数量只有10.当项目达到10.我不能添加另一个项目,因为它只取决于一行。多行验证
我有3个表到内连接。
| stockrequesttb |
----------------------
|in_code |requestqty |
| | |
| receivetb |
---------------------------------
|itemcode| status |refnumber |
| | | |
| allinvty3 |
----------------------
|in_code | item |
| | |
这里是我的代码:
<form method ="POST">
<input type="text" name="itemcode">
</form>
<?
if(isset($_POST['itemcode']))
{
$sql="SELECT allinvty3.*, receivetb.* , stockrequesttb.*, count(receivetb.itemcode) as icount from receivetb
INNER JOIN stockrequesttb on receivetb.itemcode =stockrequesttb.in_code
INNER JOIN allinvty3 on receivetb.itemcode = allinvty3.in_code
where receivetb.refnumber='$temp' group by receivetb.itemcode";
$result = $conn->query($sql);
while($row = $result->fetch_assoc())
{
$icount = $row['icount'];
$qty = $row['requestqty'];
$total1 =$row['itemcode'];
}
if($itemcode!== $total1)
{
echo"<script type=\"text/javascript\">alert('No item found'); </script>";
}
?>
这是我的问题。我做了一个sql计数,这是确保项目在请求中是相等的。这里有什么不对,它只取决于一行,如果请求的数量已经相等,我不能添加另一个项目。
<?
if($icount == $row['requestqty'])
{
echo"<script type=\"text/javascript\">alert('Over'); </script>";
}
else {
/*My INSERT CODE works here*/
}
}
?>
尝试如果($ icount> $ row ['requestqty']), –
我试过那个,但它不工作。感谢您的努力无论如何 – codeSeven