Advertisement
iftekharul

double amount by day

Mar 14th, 2020
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.25 KB | None | 0 0
  1. <form action="" method="post" enctype="multipart/form-data">
  2.     <label for="amount">Enter Amount</label>
  3.     <input type="text" name="amount">
  4.     <input type="hidden" name="today" value="<?php echo strtotime("now"); ?>">
  5.     <input type="submit" name="submit" value="Submit">
  6. </form>
  7.  
  8. <?php
  9. if(isset($_POST['submit']) && $_POST['submit'] == 'Submit') :
  10.     $strtoday = $_POST['today'];
  11.     $deadline = strtotime("31 March 2020");
  12.     $today = date("Y-m-d", $strtoday);
  13.     $endday = date("Y-m-d", $deadline);
  14.     $secs = $deadline - $strtoday;
  15.     $totalday = floor($secs / (24 * 60 * 60 ));
  16.     $amount = $_POST['amount'];
  17.     $array = array($today => $amount);
  18.     echo "Today: ".$today."<br><br>";
  19.     echo "Deadline: ".$endday."<br><br>";
  20.     echo "Total Days: ".$totalday."<br><br>";
  21.     //echo $today. " &amp; Amount = ".$amount."<br>";
  22.     for($i=0; $i<=$totalday; $i++) {
  23.         $next = strtotime("+1 day", $strtoday);
  24.         $nextday = date("Y-m-d", $next);
  25.         $nextamount = $amount * 2;
  26.         $strtoday = $next;
  27.         $amount = $nextamount;
  28.         $array[$nextday] = $nextamount;
  29.         //echo $nextday. " &amp; Amount = ".$nextamount."<br>";
  30.     }
  31.     foreach( $array as $key => $value ){
  32.         echo $key."\t=>\t".$value."\n";
  33.     }
  34. endif;
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement