In report.php class, line 94 you echo inside the class but you should use return:
return $employee_id; #last id of multiple insert In same function you should set a mysql_query() in order to insert. But it seems you want to send groups of arrays, reordered by report.php view, but there is something wrong, when you write:
$report->request_date[$i] = $_POST["request_date"]; you are not considering that multiple values are set under request_date (and also the others fields of the form), try to simply print_r() that variable: <?php print_r($_POST['request_date']); ?> and you will see an array with a value for each report form, so if there are three reports you will have three request_date values. At the moment you get six different arrays from your form and you need to create a single array, like in this example:
<html>
<head><title></title></head>
<body>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
print_r($_POST['a']);
echo "";
print_r($_POST['b']);
$neworder = '';
$c = count($_POST['a']);
for($i = 0; $i < $c; $i++)
{
$neworder[] = array($_POST['a'][$i],$_POST['b'][$i]);
}
echo "<pre>";
print_r($neworder);
echo "<pre>";
}
?>
<form method="post" action="">
a: <input type="text" name="a[]" />
b: <input type="text" name="b[]" />
a: <input type="text" name="a[]" />
b: <input type="text" name="b[]" />
<input type="submit" name="button" value="submit" />
</form>
</body>
</html> The output:
Array ( [0] => a [1] => aa ) # first report
Array ( [0] => b [1] => bb ) # last report
# single array
Array
(
[0] => Array
(
[0] => a
[1] => b
)
[1] => Array
(
[0] => aa
[1] => bb
)
) Or you can try to create part of the insert string, similar to previous example:
<html>
<head><title></title></head>
<body>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
print_r($_POST['a']);
echo "";
print_r($_POST['b']);
$neworder = '';
$c = count($_POST['a']);
for($i = 0; $i < $c; $i++)
{
$a = $_POST['a'][$i];
$b = $_POST['b'][$i];
if($i != $c-1)
{
$neworder .= "values('$a','$b'), ";
}
else
{
$neworder .= "values('$a','$b')";
}
}
echo "<pre>";
print_r($neworder); # values to insert
echo "<pre>";
}
?>
<form method="post" action="">
a: <input type="text" name="a[]" />
b: <input type="text" name="b[]" />
a: <input type="text" name="a[]" />
b: <input type="text" name="b[]" />
<input type="submit" name="button" value="submit" />
</form>
</body>
</html> The output will be:
Array ( [0] => a [1] => aa ) # first group
Array ( [0] => b [1] => bb ) # last group
# string
values('a','b'), values('aa','bb') At this point you need only to insert:
mysql_query("insert into table ('field_A','field_B') $neworder");
In order to make it work with your class, you can: send a single array (reordered) to addReport() instead of single strings just like in my first example (I think you will need to serialize* data to get the array inside the function and unserialize to get it to work again) and finally create a loop to sanitize each value and, similarly to my second example, create the values() part of the insert string.
Hope is enough clear and not too long, bye :)