title: displaying variable from php file
body: <p>I've got a discount code for shopping cart that calculates a deduction of %10, all works fine, but I'd like to display the amount that has been discounted (<code>$discount_amount</code>) as a minus value (-£2.50) or display £0.00 if no discount has been applied, just not sure how the best way to go about it is, any advice much appreciated.</p>
  
  <p>page.php:</p>
  
  <pre><code>$currency = '£';
  
  if(isset($_POST['action']) &amp;&amp; $_POST['action'] == "coupon_dis")
  {
      $couponcode = trim($_POST['couponval']);
      $amnt = $_POST['amnt'];
      $val = '0';
      if($couponcode == "loyalty10"){
          $couponDiscount_val = "10";
          $discount_amount = ($amnt*$couponDiscount_val)/100;
          $amount_after_discount = $amnt - $discount_amount;
          $val = sprintf("%01.2f", $amount_after_discount);
      }
      $_SESSION['discount_amount'] = sprintf("%01.2f", $discount_amount);
      $_SESSION['product_discount'] = $val;
      echo $currency.$val;
  }
  </code></pre>
  
  <p>javascript :</p>
  
  <pre><code>$(document).ready(function(){
  $("#addcoupon").click(function(){
      var ttlamt = $("#ttl_amount").val();
      var ccode = $("#couponcode").val();
      var cpn = ccode.replace(/\s/g, '');
      if(cpn.length &lt;= 0){
          $("#couponcode").css("border-color","red");
      }else{
        $("#couponcode").css("border-color","");
        $.ajax({
            url: "page.php",
            method: "POST",
            data: {action:"coupon_dis",couponval: cpn,amnt: ttlamt},
            cache: false,
            success: function(data){
              if(data != "0"){
                  $("#grandamount").css("display","none");
                  $("#couponcode").css("border-color","green");
                  $("#grand_discount_amount").css("display","block");
                  $("#grand_discount_amount").html(data);
              }else{
                $("#grandamount").css("text-decoration","");
                $("#couponcode").css("border-color","");
                $("#grand_discount_amount").html("");
                $("#grand_discount_amount").css("display","none");
              }
            }
        });
      }
      return false;
  });
  </code></pre>