รายละเอียดของการตอบ ::
$strSQL = "SELECT Qta_Value FROM Cnt_Quota WHERE (EmpID = '".$_POST["txtEmpID"]."') AND Qta_Value != 0";
$objQuery = sqlsrv_query($conn, $strSQL);
$objResult = sqlsrv_fetch_array($objQuery,SQLSRV_FETCH_ASSOC);
//echo $objResult["Qta_Value"];
if(!$objResult)
{
echo "<script type=text/javascript>alert('หมดตูดแล้ว !!');javascript:history.back(1);</script>";
}
else
{
$sql1 = "UPDATE Cnt_Quota SET
Qta_Qty = Qta_Qty - ? ,
Qta_Value = Qta_Value - ?
WHERE EmpID = ? ";
$params1 = array($_POST["txtQty"], $_POST["txtQty"] * 20, $_POST["txtEmpID"]);
$stmt1 = sqlsrv_query( $conn, $sql1, $params1);
if( $stmt1 === false ) {
die( print_r( sqlsrv_errors(), true));
}
else
{
echo "<script type=text/javascript>alert('จ่ายแล้ว 20 บาท');javascript:history.back(1);</script>";
exit();
}
}