How much will each service cost you?
if ($_POST['years'] and $_POST['songnumber']) { //They're passing the info in. $sn = $_POST['songnumber']; $years = $_POST['years']; if (!is_numeric($sn) || $sn < 0) { $sn = 0; } if (!is_numeric($years) || $years < 0) { $years = 0; } $itunes = 0.99 * $sn; $napster = 15 * 12 * $years * ($sn > 0); if ($itunes < $napster) { $winner = "iTunes"; } elseif ($itunes > $napster) { $winner = "Napster"; } else { $winner = "Neither"; } ?>iTunes: $ echo number_format($itunes, 2, '.', ','); ?>
Napster: $ echo number_format($napster, 2, '.', ','); ?>
if ($years <= 10) { ?>Wow, sorry about that lifespan. We'll be sad to see you go. Remember, if you use Napster, your family and friends will have to keep paying for your music, even after you're gone, if they want to keep it around to remember you by.
} ?> Try another calculation! } else { //They're not passing info in, so give them the form. ?>