View Full Version : PHP ROI calculator This is a hard one!

10-16-2004, 09:29 AM
Hi I am tring to put together this ROI calculator but I cant get the calculations right. The calculations is suppose to calculate multiply results. This is going to to be hard to explain but it calculates correct sometimes. I dont know what to do. Some calculations are right on the dot and some are just totally wrong. I have tried everything I know but still can figure it out. Any help would be great THANK YOU.

Here is the link to the calculatorROI calculator (http://www.smslists.com/roicalculator)

if ($_POST['submit'] && $_POST['responserate'] && $_POST['numberofpieces'] && $_POST['conversionrate'] && $_POST['averagespend'] && $_POST['programcost']) {
$ResponsePer = $_POST['responserate'] / 100;
$NumberResponse = $ResponsePer * $_POST['numberofpieces'];

$ConversionPer = $_POST['conversionrate'] / 100;
$buyers = $ConversionPer * $NumberResponse;

$TotalRevenue = $buyers * $_POST['averagespend'];

$CostPerBuyer = $_POST['programcost'] / $buyers;

$CostPerResponse = $_POST['programcost'] / $NumberResponse;

$CostPerPiece = $_POST['numberofpieces'] / $_POST['programcost'];
$ans = $TotalRevenue - $_POST['programcost'];
$roi = $ans / $_POST['programcost']* 100;

echo "<center><table border='2' rules='groups' frame='hsides' cellpadding='5' cellspacing= '5'>
<caption><h2><b> ROI Results</b></h2></caption></center>
echo "<tr><td> <b> # OF BUYERS</b></td><td>".round($buyers)."<td><b>Cost Per Piece</b></td><td>"."$".round($CostPerPiece)."\n";
echo "<tr><td><b># OF RESPONDERS</b></td><td>".round($NumberResponse)."<td><b>Cost Per Response</b></td><td>"."$".round($CostPerResponse)."\n";
echo "<tr><td><b>TOTAL REVENUE</b></td><td>"."$".round($TotalRevenue)."<td><b>Cost Per Buyer</b></td><td>"."$".round($CostPerBuyer)."\n";
echo "<tr><td><b>ROI</b></td><td>".$roi."%"."</td></tr>\n";


10-17-2004, 04:02 PM
Just find a working ROI calculting algorythm and use it.
No errors found. Just watch out for division by 0.
Yes I have no idea what ROI is.