Can anyone help me getting this to work? Pls!! If only one form is checked, the script works fine. But if two forms are checked I don\'t get anything at all.
//----------form.php--presents one or two checkboxed forms (depending on $no)
<FORM METHOD = \"post\" ACTION=\"calc.php\">
$sql = mysql_query(\"SELECT * FROM col1 WHERE col2 = $no \" ) or die (\"msg \");
$i=1;
while ($row = mysql_fetch_array ($sql)) {
$name=$row[\'name\'];
$fromdate = $row[\'fromdate\'];
?>
<INPUT TYPE = \"checkbox\" NAME = \"<? echo \"form$i\" ?>\" CHECKED>
<INPUT TYPE = \"TEXT\" NAME = \"<? echo \"fromdate$i\"; ?>\" VALUE =\"<? echo $fromdate; ?>\">
<INPUT TYPE = \"TEXT\" NAME = \"<? echo \"todate$i\"; ?>\" VALUE=\"<? echo $thisyear; ?>\"
<?
$i++ ;
}
<INPUT TYPE=\"SUBMIT\" VALUE=\"send\">
//-----------script calc.php
$sql = mysql_query(\"SELECT FROM col1 WHERE col2 = $no \" ) or die (\"msg\");
$i=1;
while ($row = mysql_fetch_array ($sql)) {
$name=$row[\'name\'];
if (${\"form$i\"} == \"on\") {
$result = mysql_query (\"SELECT SUM(col) AS total FROM tbl WHERE (year>=\'${\"fromdate$i\"}\' AND year <=\'${\"todate$i\"}\' )\");
list ($total) = mysql_fetch_row($result);
$usersum = ($total $y)/100 ;
}
<? echo $name; echo sprintf(\'%d\', $usersum);
$i++;
}