| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- include_once "../../include/DB.php";
- $TotalRechargedSwapCount=0;
- $UsedRechargedSwapCount=0;
- $AvailableRechargedSwapCount=0;
- $SwapRechargeID="";
- if (isset($_POST["TotalRechargedSwapCount"]) && !empty($_POST["TotalRechargedSwapCount"])) {
- $TotalRechargedSwapCount=$_POST["TotalRechargedSwapCount"];
- }
- if (isset($_POST["UsedRechargedSwapCount"]) && !empty($_POST["UsedRechargedSwapCount"])) {
- $UsedRechargedSwapCount=$_POST["UsedRechargedSwapCount"];
- }
- if (isset($_POST["AvailableRechargedSwapCount"]) && !empty($_POST["AvailableRechargedSwapCount"])) {
- $AvailableRechargedSwapCount=$_POST["AvailableRechargedSwapCount"];
- }
- if (isset($_POST["SwapRechargeID"]) && !empty($_POST["SwapRechargeID"])) {
- $SwapRechargeID=$_POST["SwapRechargeID"];
- }
- $SwapRechargeUpdateSql = "UPDATE swaprecharge SET TotalRechargedSwapCount='$TotalRechargedSwapCount',UsedSwapCount='$UsedRechargedSwapCount',AvailableSwapCount='$AvailableRechargedSwapCount' WHERE SwapRechargeID='$SwapRechargeID'";
- $SwapRechargeUpdateResult = $conn->query($SwapRechargeUpdateSql);
- if ($SwapRechargeUpdateResult === TRUE) {
- $value = array(
- "SwapRechargeID"=>(int)$SwapRechargeID,
- "TotalRechargedSwapCount"=>(int)$TotalRechargedSwapCount,
- "UsedRechargedSwapCount"=>(int)$UsedRechargedSwapCount,
- "AvailableRechargedSwapCount"=>(int)$AvailableRechargedSwapCount,
- "Message"=>"Swap recharge data saved successfully",
- );
- // Use json_encode() function
- $json = json_encode($value);
- }else {
- http_response_code(404);
- $errorMesage= $conn->error;
- // Declare an array with error message
- $value = array(
- "Message"=>"Something went wrong",
- "Error"=>$errorMesage
- );
- // Use json_encode() function
- $json = json_encode($value);
- }
- // Display the output
- echo ($json);
- $conn->close();
|