i've come up with the following script, i have a problem though, when i try and run it i get a, 'parse error on line 52 error' (in my editor line 52 is the line $temp_mon = "mon$i"😉
i have looked all the way through and can't seem to find an error (i am new to this though so i am probably missing an obvious problem.)
please help its driving me nuts!!
TIA
jamie
<?
/ checks if number of rows is specified otherwise give a default value /
if ($numrows)
{
$numrows = $numrows ;
}
else
{
$numrows = 6 ;
}
/ now check if submitting a form/
if ($been=="Y")
{
/s ubmitting a form /
/ setup some variables for mail /
$email .="@benenden-healthcare.org.uk";
$recipient .="Sickness Report Collector<jamie.kerwick@benenden-healthcare.org.uk>";
$subject = "Sickness Report";
$headers .= "From: Sickness Report: <$email>\n";
$headers .= "X-Sender: <$email>\n";
$headers .= "X-Mailer: Intranet Mailer\n";
$headers .= "Return-Path: <jamie.kerwick@benenden-healthcare.org.uk>\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\n";
$headers .= "cc: $email\n";
$headers .= "bcc: james@lkerwick.freeserve.co.uk";
$message .= "<h1 align=\"center\">Sickness Report for $dept department by <a href=\"mailto:$email\">$realname</a> for WC $week</h1>
<div align=\"center\"> <table border=\"1\" width=\"75%\" cellspacing=\"0\" cellpadding=\"0\"><tr align=\"center\">
<td width=\"149\" colspan=\"5\" align=\"center\">Days Recorded Sick</td>
<td width=\"167\" rowspan=\"2\" align=\"center\">Name</td>
<td width=\"35\" rowspan=\"2\" align=\"center\">Self<br>Cert</td>
<td width=\"36\" rowspan=\"2\" align=\"center\">DR's <br> Cert</td>
<td width=\"128\" align=\"center\" rowspan=\"2\">Date of Return to Work MTG</td>
<td width=\"91\" align=\"center\" rowspan=\"2\">Staff <br> Number</td>
<td width=\"68\" align=\"center\" rowspan=\"2\">SSP <br> Days</td>
</tr>
<tr align=\"center\">
<td width=\"29\" align=\"center\">Mon</td>
<td width=\"25\" align=\"center\">Tue</td>
<td width=\"28\" align=\"center\">Wed</td>
<td width=\"30\" align=\"center\">Thu</td>
<td width=\"29\" align=\"center\">Fri</td>
</tr>";
/ begin for loop /
for ($i=1; $i <= $numrows; $i++)
{
$temp_name = "name$i";
$temp_mon = "mon$i":
$temp_tue = "tue$i";
$temp_wed = "wed$i";
$temp_thur = "thur$i";
$temp_fri = "fri$i";
$temp_mtg = "mtg$i";
$temp_sc = "sc$i";
$temp_dc = "dc$i";
$temp_staffnumber = "staffnumber$i";
$temp_ssp = "ssp$i";
if (!$$temp_name && ($$temp_mon || $$temp_tue || $temp_wed || $temp_thur || $temp_fri))
{
/ days without names /
$error +=1;
$errormessage .= "You didn't give a name to days you ticked on row $i<br>";
}
elseif ($$temp_name && (!$$temp_mon && !$$temp_tue && !$$temp_wed && !$$temp_thur && !$$temp_fri))
{
/ names without days /
$error +=1;
$errormessage .= "You entered a name without any sick days on row $i<BR>";
}
elseif (!$$temp_name && (!$$temp_mon && !$$temp_tue && !$$temp_wed && !$$temp_thur && !$$temp_fri))
{
/ count empty days /
$emptydays +=1 ;
}
else
{
/ content is fine so render the row /
$message .="<tr align=\"center\">
<td width=\"29\"> $$temp_mon</td>
<td width=\"25\"> $$temp_tues</td>
<td width=\"28\"> $$temp_wed</td>
<td width=\"30\" align=\"center\"> $$temp_thur</td>
<td width=\"29\" align=\"center\"> $$temp_fri</td>
<td width=\"167\"> $$temp_name</td>
<td width=\"35\" align=\"center\"> $$temp_sc</td>
<td width=\"36\" align=\"center\"> $$temp_dc</td>
<td width=\"128\"> $$temp_mtg</td>
<td width=\"91\"> $$temp_staffnumber</td>
<td width=\"68\"> $$temp_ssp</td>
</tr>";
}
/ end for loop /
}
/ check for errors and blank report /
if ($error !="")
{
print "$error error(s) have occured, please go <a href=\"/forms/sickness.php\">back</a> and correct them<br>";
print "Details of the errors .... <br><br>";
print "$errormessage";
}
elseif ($emptydays == $numrows)
/check for blank report/
{
print "<h1>You submitted a report with no absences<h1>. <p>Remember only submit a form if you DO have absences. If this was a mistake go <a href=\"/forms/newsickness.php\">back</a> and try again.";
}
else
{
/ close table tags /
$message .= "<tr align=\"center\">
<td width=\"666\" colspan=\"11\"> </td></tr></table></div>
" ;
mail( $recipient, $subject, $message, $headers);
print "$message";
}
}
/ end of if been=="Y" /
else
{
/ not submitting so draw table (start of if been !="Y"/
/ draw the column titles for the table/
?>
<table border="0" width="95%" align="center">
<tr>
<td > </td>
<td align="right"><a href="\">Home</a> </td>
</tr>
<tr>
<td colspan="2" >
<h1 align="center">Sickness Report</h1>
</td>
</tr>
</table>
<p align="center">Please Complete the form for your team/department.</p>
<p align="center">Enter only details for members of staff who have been off on
sick leave.</p>
<p align="center"><b>Please Note</b>: you DO NOT need to submit a nil return.</p>
<div align="center">
<form action="<? echo $PHP_SELF; ?>" method="POST">
<input type="hidden" name="been" value="Y">
<table border="1" width="690" cellspacing="0" cellpadding="0">
<tr>
<td width="42"> Name</td>
<td width="168">
<input type="text" name="realname" size="20">
</td>
<td width="124"> Email (first.surname)</td>
<td width="171">
<input type="text" name="email" size="20">
</td>
<td width="37">W/C</td>
<td width="133">
<input type="text" name="week" size="15">
</td>
</tr>
<tr>
<td width="42">Dept</td>
<td width="168">
<input type="text" name="dept" size="20">
</td>
<td width="124"> </td>
<td width="171"> </td>
<td width="37"> </td>
<td width="133"> </td>
</tr>
</table>
<table border="1" width="690" cellspacing="0" cellpadding="0">
<tr>
<td width="149" colspan="5" align="center"> Days Recorded Sick</td>
<td width="167" rowspan="2" align="center"> Name</td>
<td width="35" rowspan="2" align="center"> Self<br>
Cert</td>
<td width="36" rowspan="2" align="center"> DR's <br>
Cert</td>
<td width="128" align="center" rowspan="2"> Date of Return to Work MTG</td>
<td width="91" align="center" rowspan="2"> Staff <br>
Number</td>
<td width="68" align="center" rowspan="2"> SSP <br>
Days</td>
</tr>
<tr>
<td width="29" align="center"> Mon</td>
<td width="25" align="center"> Tue</td>
<td width="28" align="center"> Wed</td>
<td width="30" align="center"> Thu</td>
<td width="29" align="center"> Fri</td>
</tr>
<?
/ begin a for loop to draw each row /
for ($i=1; $i <= $numrows; $i++)
{
/ define temporary variables to give dynamic form field names /
$temp_name = "name$i";
$temp_mon = "mon$i":
$temp_tue = "tue$i";
$temp_wed = "wed$i";
$temp_thur = "thur$i";
$temp_fri = "fri$i";
$temp_mtg = "mtg$i";
$temp_sc = "sc$i";
$temp_dc = "dc$i";
$temp_staffnumber = "staffnumber$i";
$temp_ssp = "ssp$i";
print "<tr align=\"center\">
<td width=\"29\">
<input type=\"checkbox\" name=\"$temp_mon\" value=\"X\">
</td>
<td width=\"25\">
<input type=\"checkbox\" name=\"$temp_tue\" value=\"X\">
</td>
<td width=\"28\">
<input type=\"checkbox\" name=\"$temp_wed\" value=\"X\">
</td>
<td width=\"30\" align=\"center\">
<input type=\"checkbox\" name=\"$temp_thur\" value=\"X\">
</td>
<td width=\"29\" align=\"center\">
<input type=\"checkbox\" name=\"$temp_fri\" value=\"X\">
</td>
<td width=\"167\">
<input type=\"text\" name=\"$temp_name\" size=\"20\">
</td>
<td width=\"35\" align=\"center\">
<input type=\"checkbox\" name=\"$temp_sc\" value=\"X\">
</td>
<td width=\"36\" align=\"center\">
<input type=\"checkbox\" name=\"$temp_dc\" value=\"X\">
</td>
<td width=\"128\">
<input type=\"text\" name=\"$temp_mtg\" size=\"15\">
</td>
<td width=\"91\">
<input type=\"text\" name=\"$temp_staffnumber\" size=\"10\">
</td>
<td width=\"68\">
<input type=\"text\" name=\"$temp_ssp\" size=\"7\">
</td>
</tr> ";
/ finished drawing row end for loop/
}
?>
<tr>
<td width="666" colspan="11">
</tr>
</table>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
</div>
<?
/ end if been !="Y" /
}
?>
</body>