Jump to content

Maths and rounding £0.83000000000001


otuatail

Recommended Posts

Money in	Money Out	Balance	
				£101.84 
		£10.00 		 £91.84 
		 £1.05 		 £90.79 
		 £1.96 		 £88.83 
		£88.00 		  £0.83000000000001 

<?
// Banking Version 1.0.0   22-07-2015   Desmond O'Toole.
require("../secure/SecureFunctions.php");
include ("secure/SecureFunctionsBank.php");
session_start();
Session_Init();
$page = "Libray Selection";

if(!isset($_SESSION["Pk"]))
{
  header('Location: index.php');
  exit;
}

$Pk = $_SESSION["Pk"];
if(KeyCheckX($Pk)== 0)
{
  header('Location: index.php');
  exit;
}


if(isRoguebot($Browser) == 1)
  exit;

$_SESSION["K9"] =  isRobot($Browser);

if($_SESSION["current_page"] <> $page && $_SESSION['Event_Log'] == "YES")
{
   StoreData($page);
   mailtoX($page,"Desmonds New Site.",""); 
}
$_SESSION["current_page"] = $page;

$filename = filename($_SERVER['PHP_SELF']);
$Update = date("D d-M-Y H:i", filectime($filename));

$qBalance = GetBalance();
$row = mysql_fetch_array($qBalance);
$Date = $row['EntryDate'];
$Value = $row['BalanceValue'];
$stamp =  strtotime($Date);
//$ViewDate = date('D d-M-Y' ,$stamp);
$StartDate = date('D d-M-Y' ,$stamp);

//$QueryDate = date('d-M-Y' ,$stamp);
$qGetAllData = GetAllData($Date);

$curValue = $Value;

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Pages Home</title>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META http-equiv="imagetoolbar" CONTENT="no">
<meta http-equiv="refresh" content="60">
<link rel="stylesheet" href="stylesheets/Library.css" type="text/css">
<link rel="stylesheet" href="stylesheets/LibraryMenu.css" type="text/css">
</head>

<body>

<div id="PageTitle">
	<img src="images/LibraryBanner.jpg" alt="">
</div>

<?
 include('SideMenu.php');
?>

<div id="PageContent">
    <form action="menu.php" method="post">
    <h3>User: <?=greeting()?></h3>
     <h4><? echo MonthlTakings()?></h4>
    <div style="width:720px;padding:0px;float:left;">
        <div style="width:120px;height:10px;padding:10px;float:left;"><b>         Date</b>
        </div>
        <div style="width:70px;height:10px;padding:10px;float:left;"><b>Money In</b>
        </div>
        <div style="width:70px;height:10px;padding:10px;float:left;"><b>Money Out</b>
        </div>
         <div style="width:70px;height:10px;padding:10px;float:left;"><b>Balance</b>
        </div>
       <div style="width:70px;height:10px;padding:10px;float:left;"><b>Reason</b>
        </div>
        <div style="width:190px;height:10px;padding:10px;float:left;"><b>Comment</b>
        </div>

        <div style="width:120px;height:4px;padding:10px;text-align:right;float:left;clear:both"><a href="DataInput.php"><?=$StartDate?></a>
        </div>
        <div style="width:70px;height:4px;padding:10px;text-align:right;float:left;">
        </div>
        <div style="width:70px;height:4px;padding:10px;text-align:right;float:left;">
        </div>
        <div style="width:70px;height:4px;padding:10px;text-align:right;float:left;">£<?=$Value?>
        </div>
        <div style="width:70px;height:4px;padding:10px;float:left;">
        </div>
        <div style="width:190px;height:4px;padding:10px;float:left;">Brought forward
        </div>
		<?
		while($row = mysql_fetch_array($qGetAllData))
		{
			$stamp =  strtotime($row['EntryDate']);
			$ViewDate = date('D d-M-Y' ,$stamp);
			$CurDate = date('D d-M-Y' ,time());

			$input = '£' . $row['Input'];
			if($row['Input'] == '0.00')
				$input = "";

			$out = '£' . $row['Output'];
			if($row['Output'] == '0.00')
				$out = "";
			
			$reason = GetReasonName($row['Reason']);
			$colorSelect = ColourPicker($row['Reason'],$row['EntryDate']);
			
			$curValue = $Value + $row['Input'] - $row['Output'];
			$curValue = RestoreDecimal($curValue);
			$Value = $curValue;
			
			$Comment = $row['Comment'];
			
			//$ID = TransposeKey($row['Tag']);
			$ID = $row['Tag'];
			$x = "";
			//if($CurDate == $ViewDate)
			//   $x = "background-color:#cdcccc;";
			// background-color:#6495ed;
		if($colorSelect == "#777777") {
		?>
        <div style="width:120px;height:4px;padding:10px;text-align:right;float:left;text-color:green;clear:both"><?=$ViewDate?></div>
        <? } else { ?>        
        <div style="width:120px;height:4px;padding:10px;text-align:right;float:left;text-color:green;clear:both"><a href="StatmentEntry.php?ID=<?=$ID?>"><?=$ViewDate?></a></div>
        <? } ?>
        <div style="width:70px;height:4px;padding:10px;color:<?=$colorSelect?>;<?=$x?>text-align:right;float:left;"><?=$input?>
        </div>
        <div style="width:70px;height:4px;padding:10px;color:<?=$colorSelect?>;<?=$x?>text-align:right;float:left;"><?=$out?>
        </div>
        <div style="width:70px;height:4px;padding:10px;color:<?=$colorSelect?>;<?=$x?>text-align:right;float:left;">£<?=$curValue?>
        </div>
        <div style="width:70px;height:4px;padding:10px;color:<?=$colorSelect?>;<?=$x?>float:left;"><?=$reason?>
        </div>
        <div style="width:190px;height:4px;padding:10px;color:<?=$colorSelect?>;<?=$x?>float:left;"><?=$Comment?>
        </div>
		<?
		}
		?>
        <div style="width:70px;height:1px;padding:10px;float:left;clear:both"> </div>
    </div>
    <div style="width:670px;height:50px;padding:0px;float:left;">
    <input class="MyButton"type="submit" name="direction" value="Main Menu">
    <br>
    </div> 
    </form>
</div>
</body>
</html>

Hi I have data from a database table. The table holds simply the date, Money going in, Money going out and a reason fro the transaction. I simply have a rolling balance which is calculated on the fly as the page is created using the data. What I have is this. But all I am doing is adding and subtracting. I could understand it if I divided 1/3

Edited by otuatail
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.