That worked! Thanks so much, I appreciate all your help on this topic. I do have another questions, however. So far, the script can collect all the data from the form and print it on the page, but I need to have it emailed. However, how would it be possible to email the process below. I tried to assign the results of the foreach function to a variable or an array, but it would not loop, so I all I got was the last answer.
Code: Select all
<?php
$t1s2 = array(1 => "D", 2 => "B", 3 => "E", 4 => "C", 5 => "A", 6 => "B", 7 => "A", 8 => "D", 9 => "E", 10 => "B", 11 => "D", 12 => "D", 13 => "E", 14 => "D", 15 => "B", 16 => "A", 17 => "A", 18 => "C", 19 => "A", 20 => "B", 21 => "B", 22 => "C", 23 => "B", 24 => "A");
$t1s2c = 0;
$t1s2s = array(0 => "N/A");
while($q <= 30)
{
$var = $_POST["q2_$q"];
$t1s2s["$q"] = "$var";
$q++;
}
echo "<P><table border=1><tr><td align=left colspan=4><b>Section 2</b></td>"
."<tr><td align=center>#</td><td align=center>R</td>"
."<td align=center>A</td><td align=center>W</td></tr>";
// I would like the result of this to be printed in an email message
foreach ($t1s2s as $n => $ss)
{ foreach ($t1s2 as $k => $sw)
{if ($n == $k)
{ if ($ss == $sw)
{ $t1s2c++;
echo "<tr><td>$n.</td><td>$sw</td><td>$ss</td><td> </td></tr>";
}
else
echo "<tr><td>$n.</td><td>$sw</td><td>$ss</td><td>x</td></tr></tr>";
} }
}
echo "<tr><td colspan=4>$t1s2c correct.</td></tr></table><P>";
Thanks again.
-Vi