Help!
Ok...I'm having a mind blank....I have a table with six columns named retirement1, retirement2, retirement3, retirement4, retirement5, retirement6. Each column stores a number from 0-5. I would like to total up how many 5's are in each column, how many 4's are in each column, etc... I can get the inner loop working where it counts the numbers in the first column, but I can't get the outer loop working where it will add 1 to the number on the end of the word retirement and loop through all of this again. Can someone help?? Here is the code I have so far:
$sql = "SELECT * FROM hrsurvey_retirement";
$result = mssql_query($sql);
$num_results = mssql_num_rows($result) or die ("The query: '$sql' did not return any data");
for ($count=0; $count<6; $count++)
{
$five=0;
$four=0;
$three=0;
$two=0;
$one=0;
$zero=0;
echo "retirement".$count;
for ($i=0; $i<$num_results; $i++)
{
$row = mssql_fetch_row($result);
$retirement1 = mssql_result($result, $i, "retirement1");
if ($retirement1 == "5") {
$five = $five+1;
echo " five=".$five;
}
if ($retirement1 == "4") {
$four = $four+1;
echo " four=".$four;
}
if ($retirement1 == "3") {
$three = $three+1;
echo " three=".$three;
}
if ($retirement1 == "2") {
$two = $two+1;
echo " two=".$two;
}
if ($retirement1 == "1") {
$one = $one+1;
echo " one=".$one;
}
if ($retirement1 == "0") {
$zero = $zero+1;
echo " zero=".$zero;
}
}
}
