Monday, February 4, 2013

Php Percent Of Profit Calculator Function

To customize this remove the =100 and =50 from the variable values. Place this into a php page and use a form to pass the values and sanitize them then add the function call line  below that to show output of this calculator. You will need two inputs to be passed one for Retail and One for Cost.

function percentOf($retail=100, $cost=50)
 $profit = ($retail - $cost);
 $percent = ($profit / $retail);
 $totalpercent = ($percent * 100);
 echo 'Total Retail
 echo $retail;
 echo '
Subtract Total Cost
Equals Profit $';
 echo $profit;
 echo '
Percent Total=';
 echo $percent;
 echo '%
You made a ';
 echo $totalpercent;
 echo ' percent profit';
  //return $link;

} // end function percentOf()

echo percentOf();

No comments:

Post a Comment