<?php
    include 'load.php';
    require_once 'db_connection.php'; 
    
    
    
    if(isset($_POST['all_discount'])){
        $all_discount =  $_POST['all_discount'];
        $lastchar = substr($all_discount, -1); 
        if($lastchar=="%"){
            $dis = intval(substr($all_discount, 0, -1));
            $distype = 1;
        }else{
            $dis = $all_discount;
            $distype = 0;
        }

       $sql = "UPDATE all_discount_tbl SET discount_val='$dis',discount_type='$distype' WHERE all_discount_tbl_id='1'";
 
        if ($conn->query($sql) === TRUE) {
             echo 1;
        }else{
             echo 0;
        }
     }
     
?>