i am currenty working on a system where users can fill out a time report sheet with the hours and type of work they have been doing.
The problem is that the input fields on the first page are named after the rows and entries, so for example if a user wanted to fill in a time report sheet for one week then there would be 7 input boxes for date and 7 for all the other fields of input. so the names of the date input boxes would be date11, date12, date13 etc... and if they wanted to enter 2 entries per day then the date input boxes would be date11, date21, date12, date22, date13 etc...
So when i post the form to the next page to be entered into the mysql database i run the 2 loops again but i cant use the code $tempdate = $date + $firstloopnum + $secondloopnum; as $date doesn't exist so i need to add the two loop numbers on to the end of $date and store that as a variable
eg ( $date + $firstloop + $secondloop = $date11)
below is my database insert code:
<?
for($i=1;$i<$two;$i++){
for($j=1;$j<$one+1;$j++){
$db = @mysql_pconnect("localhost", "name", "password");
if (!$db)
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}
$emp=$employeeid + $j + $k;
$dat=$date+$j+$i;
$project=$projectid+$j+$i;
$act=$activitycodeid+$j+$i;
$hour=$hours+$j+$i;
mysql_select_db("time_sheets");
$query = "insert into time_reports (employeeid, date , projectid, activitycodeid, hours) values ('$emp', $dat, $project, $act, $hour)";
$result = mysql_query($query);
if ($result)
{
echo "added to the database";
}
}
}
?>