Cool!
I have created a file called functions.php
<?php
require "./connect.php";
//////////// GET TT&L ////////////////////
function get_ttl() {
global $tradediff,$tax,$saleprice,$rebate,$cashprice,$vit
,
$taxamount,$vitamount,$doc,$title,$registration;
$retVal = mysql_fetch_array(mysql_query("SELECT * FROM ttl"));
$retVal['taxamount'] = $tradediff*$tax;
$retVal['cashprice'] = $saleprice-$rebate;
$retVal['vitamount'] = $cashprice*$vit;
$retVal['amountfinanced'] = $cashprice+$taxamount+
$vitamount+$doc+$title+$registration;
return $retVal;
}
//////////// GET TT&L ////////////////////
?>
How would I call it in the following page where indicated that will produce the needed variables?
<?php
require "./connect.php";
include "./header.inc";
include "./functions.php";
///-------PRE-SET----------///
$tradediff = $saleprice-$rebate-$tradevalue;
//$date = date("l h:i A");
$today = getdate();
$date = ("".$today['mon']."-".$today['mday']."-".$today['year']."");
///-------PRE-SET----------///
//// *** NEED TO CALL IT HERE *** /////
echo "<form method=\"post\" action=\"index.php\">\n";
//echo "<input type=hidden name=\"id\" value=\"$id\">\n";
if ($submit) {
if ($overridedown) {
$cashdown = $taxamount;
}
$sql = "INSERT INTO deals (date,saleprice,rebate,tradevalue,tradepayoff,cashdown,msrp,residual,firstname,lastname,beacon) VALUES ('$date','$saleprice','$rebate','$tradevalue','$tradepayoff','$cashdown','$msrp','$residual','$firstname','$lastname','$beacon')";
} elseif ($edit) {
echo "2";
$sql = "UPDATE deals SET saleprice='$saleprice',rebate='$rebate',tradevalue='$tradevalue',tradepayoff='$tradepayoff',cashdown='$cashdown',firstname='$firstname',lastname='$lastname',beacon='$beacon' WHERE id=$id";
?>
<?php
}
$result = mysql_query($sql);
////////
// Find the last insert row
$id = mysql_insert_id();
////////
$sixtymonthpmt = $amountfinanced*.0240;
$fortyeightmonthpmt = $amountfinanced*.0280;
$thirtysixmonthpmt = $amountfinanced*.0311;
?>
<?php
include "./maintemplate.inc";
include "./footer.inc";
?>