Perhaps something without the basic language construct of an if would help. Here's one that only uses two "advanced" functions:
1.) [man]foreach[/man]/b - Itterates through each item of an array
2.) [man]count[/man]/b - Counts the number of elements in an array starting at 1.
Using those two functions you can go over 1 array, count the number of each type of system's game, and then calculate the total. Very very easy:
<?php
$_PRICES = array(
'NES' => 500,
'SNES' => 800,
'N64' => 1000,
'GEN' => 800,
'TURBO' => 600,
);
$total_points = 0;
foreach($_POST['games'] AS $type=>$arr)
{
$multiplier = count($arr);
$total_points += $_PRICES[$type]*$multiplier;
}
echo 'You would stand to lose ', $total_points, ' Wii points.';
?>
<html>
<head>
<title>Virtual Console Calculator</title>
<script type="text/javascript" language="Javascript"><!-- // --><![CDATA[
function getElementsByClassName(oElm, strTagName, strClassName)
{
var arrElements = (strTagName == "*" && oElm.all) ? oElm.all : oElm.getElementsByTagName(strTagName);
var arrReturnElements = new Array();
strClassName = strClassName.replace(/\-/g, "\\-");
var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
var oElement;
for (var i=0; i<arrElements.length; i++)
{
oElement = arrElements[i];
if(oRegExp.test(oElement.className))
{
arrReturnElements.push(oElement);
}
}
return(arrReturnElements);
}
function selectAll(oElm, strTagName, cName, group)
{
var elmnts = getElementsByClassName(oElm, strTagName, cName);
for(var i=0; i<elmnts.length; i++)
{
if(group.checked==true)
elmnts[i].checked=true;
else
elmnts[i].checked=false;
}
}
// ]]></script>
</head>
<body>
Welcome one, welcome all!
To this Virtual Console Calculator. This script is to help you decide on what Virtual Console games you'd like to download onto your Nintendo Wii. Simply check the boxes of the game(s) you'd like to download & (how many wii points you'd have after the last download is done), and input (at the bottom) amount of Wii points you have, and submit.
<form action='' method='POST'>
<table border='0' width='100%'>
<tr>
<th colspan='5' style="text-align: left;"><input type="checkbox" onClick="selectAll(document, 'input', 'NES', this);" /><strong>N</strong>intendo <strong>E</strong>ntertainment <strong>S</strong>ystem</th>
</tr>
<tr>
<td><input type="checkbox" name="games[NES][]" class="NES" />Donkey Kong </td>
<td><input type="checkbox" name="games[NES][]" class="NES" />Mario Bros </td>
<td><input type="checkbox" name="games[NES][]" class="NES" />Pinball </td>
<td><input type="checkbox" name="games[NES][]" class="NES" />Soccer </td>
<td><input type="checkbox" name="games[NES][]" class="NES" />Solomon's Key </td>
</tr>
<tr>
<td><input type="checkbox" name="games[NES][]" class="NES" />Legend of Zelda </td>
<td><input type="checkbox" name="games[NES][]" class="NES" />Wario's Woods </td>
<td><input type="checkbox" name="games[NES][]" class="NES" />Donkey Kong Jr </td>
<td><input type="checkbox" name="games[NES][]" class="NES" />Ice Hockey </td>
<td><input type="checkbox" name="games[NES][]" class="NES" />Tennis </td>
</tr>
<tr>
<td><input type="checkbox" name="games[NES][]" class="NES" />Super Mario Bros </td>
<td><input type="checkbox" name="games[NES][]" class="NES" />Baseball </td>
<td><input type="checkbox" name="games[NES][]" class="NES" />Urban Champion </td>
</tr>
<tr>
<td colspan="5"></td>
</tr>
<tr>
<th colspan='5' style="text-align: left;"><input type="checkbox" onClick="selectAll(document, 'input', 'SNES', this);" /><strong>S</strong>uper <strong>N</strong>intendo <strong>E</strong>ntertainment <strong>S</strong>ystem</th>
</tr>
<tr>
<td><input type="checkbox" name="games[SNES][]" class="SNES" />F-Zero </td>
<td><input type="checkbox" name="games[SNES][]" class="SNES" />SimCity </td>
<td><input type="checkbox" name="games[SNES][]" class="SNES" />Street Fighter II: The World Warrior </td>
<td><input type="checkbox" name="games[SNES][]" class="SNES" />Super Castlevania IV </td>
<td></td>
</tr>
<tr>
<td colspan="5"></td>
</tr>
<tr>
<th colspan="5" style="text-align: left;"><input type="checkbox" onClick="selectAll(document, 'input', 'N64', this);" /><strong>N</strong>intendo <strong>64</strong></th>
</tr>
<tr>
<td><input type="checkbox" name="games[N64][]" class="N64" />Mario 64 </td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="5"></td>
</tr>
<tr>
<th colspan="5" style="text-align: left;"><input type="checkbox" onClick="selectAll(document, 'input', 'GEN', this);" />Sega Genesis</th>
</tr>
<tr>
<td><input type="checkbox" name="games[GEN][]" class="GEN" />Altered Beast </td>
<td><input type="checkbox" name="games[GEN][]" class="GEN" />Sonic The Hedgehog </td>
<td><input type="checkbox" name="games[GEN][]" class="GEN" />Ecco the Dolphin </td>
<td><input type="checkbox" name="games[GEN][]" class="GEN" />Golden Axe </td>
<td><input type="checkbox" name="games[GEN][]" class="GEN" />Columns </td>
</tr>
<tr>
<td><input type="checkbox" name="games[GEN][]" class="GEN" />Ristar </td>
<td><input type="checkbox" name="games[GEN][]" class="GEN" />Dr. Robotnik's Mean Bean Machine </td>
<td><input type="checkbox" name="games[GEN][]" class="GEN" />Gunstar Heroes </td>
<td><input type="checkbox" name="games[GEN][]" class="GEN" />Space Harrier II </td>
<td><input type="checkbox" name="games[GEN][]" class="GEN" />ToeJam & Earl </td>
</tr>
<tr>
<td colspan="5"></td>
</tr>
<tr>
<th colspan="5" style="text-align: left;"><input type="checkbox" onClick="selectAll(document, 'input', 'TURBO', this);" />Turbo Grafix 16 </th>
</tr>
<tr>
<td><input type="checkbox" name="games[TURBO][]" class="TURBO" />Bomberman '93 </td>
<td><input type="checkbox" name="games[TURBO][]" class="TURBO" />Bonk's Adventure </td>
<td><input type="checkbox" name="games[TURBO][]" class="TURBO" />Super Star Soldier </td>
<td><input type="checkbox" name="games[TURBO][]" class="TURBO" />Victory Run </td>
<td><input type="checkbox" name="games[TURBO][]" class="TURBO" />Alien Crush </td>
</tr>
<tr>
<td><input type="checkbox" name="games[TURBO][]" class="TURBO" />Military Madness </td>
<td><input type="checkbox" name="games[TURBO][]" class="TURBO" />R-Type </td>
</tr>
</table>
<input type="text" value="" /> <input type="submit" name="submit" value="Calculate Wii points" /> <input type="reset" value="Reset this form" />
</form>
</body>
</head>
</html>
Note: I updated your HTML to be valid. I also added a little Javascript so that you can just select the system name, and it'd select all subsequent games for that system.
See it in action!!
Follow Me to calculate your Wii!!!