PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Marco Tonnicchi   PHP Compound Interest Calculator   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example file
Class: PHP Compound Interest Calculator
Calculate compound interest for a given duration
Author: By
Last change:
Date: 8 years ago
Size: 2,162 bytes
 

Contents

Class file image Download
<?php
error_reporting
( E_ERROR);
 
 
?>
<style TYPE="text/css" MEDIA=screen>

 .error {
     color:red;

 }
    table {
    border-collapse: separate;
    border: 3px solid #585858;
}
td, th {
    padding: .5em;
}
th:first-child {
    padding-left: .4em;
}
th:last-child, td:last-child {
    padding-right: .4em;
}

th {
    font-weight: normal;
    text-align: center;
    border: 3px solid #FFF;
    background-color: #808080;
    color:white;
    font-weight: bold;
}

td {
    text-align: left;
     border: 2px solid #000000;
}
  </style>
 <form>
 <pre>
  Currency : <input type="text" name="currency" value="<?php print $_GET['currency'] ? $_GET['currency']:'$'; ?>">
  Initial capital : <input type="text" name="initial_capital" value="<?php print $_GET['initial_capital'] ? $_GET['initial_capital']:0; ?>">
  Saving amount : <input type="text" name="saving_amount" value="<?php print $_GET['saving_amount'];?>">
  Period in years : <input type="text" name="period" value="<?php print $_GET['period'];?>">
  Interest rate % : <input type="text" name="interest_rate" value="<?php print $_GET['interest_rate'];?>">
  Dynamics % : <input type="text" name="dynamics" value="<?php print $_GET['dynamics'] ? $_GET['dynamics']:0; ?>">
  Interval : <select name="interval">

<?php
 
require_once('class_compbound.php');
 
$label = array('12'=>'monthly','4'=>'quarterly','2'=>'half-yearly','1'=>'yearly');

        if(
$_GET['interval'] ) $iw = $_GET['interval'];
      foreach(
$label as $value => $key )
     {
        
$value = trim($value);
        
$sel = $iw == $value ? 'selected':'';
         print
'<option value="'.$value.'" '.$sel.' >'.$key.'</option>'."\n";
        
     }
?>
</select>
  <input type="submit">
 </pre>
 </form>


<?php
 
if( !$_GET['period'] || !$_GET['interest_rate']) die;
 
$Interest = new compboundInterest;
 if(
$_GET['currency'] ) $Interest->currency = $_GET['currency'];
 
 print
$Interest->create( $_GET['initial_capital'], $_GET['saving_amount'],$_GET['period'],$_GET['interest_rate'],$_GET['interval'],$_GET['dynamics']);
 
 
?>