I am having problems getting the user selected form info to inserted into the mysql database.
I am also rec eving an error:
Warning: Variable passed to each() is not an array or object in
D:\web_server\webroot\common_list_process.php on line
1) I can display the contents of the $op array (see below)
2) Am I using the correct loop to unpact the array for inserting into the
database?
3) I have attempeted to correct the error: "Variable passed to each()
is not an array or object".
I don't understand why it is happening.
4) I am willing to consider another approach to accomplishing this.
<html>
<head></head>
<body>
<!-----------------------form processor---------------------------->
<form action="../common_list_process.php" method="post">
<table>
<tr>
<td> <input type="submit" name="fee_button" value="Submit"
style="color: #ff6600;font-weight:bold; margin-right: 5;"/> </td>
</tr>
</table>
<?php
display();//display form selection and input boxes
?>
</form>
</body>
</html>
<?php
[B]/***------------display function------------**/
[/B] //display form selection and input boxes
function display()
{
$op = array();//create empty array
/****This form consist of multiple rows like this****/
echo "<table>\n";
echo "<tr height=\"10\">\n";
echo "<td width=\"9%\" bgcolor=\"#fff8dc\" align=\"\"><span class=\"style15\">
<input type=\"checkbox\" name=\"op[choice][]\" value=\"A1\">
<span class=\"style1\" >A1</span></span></td>
<td width=\"2%\" bgcolor=\"#fff8dc\" height=\"10\">
<input type=\"text\" name=\"op[unit][]\" size=\"1\" maxlength=\"2\" value =\"$a_unit\"/></td>
<td width=\"32%\" bgcolor=\"#ebeae0\" class=\"style11\">General</td>\n";
echo "<td width=\"9%\" bgcolor=\"#fff8dc\" align=\"\"><span class=\"style15\">
<input type=\"checkbox\" name=\"op[choice][]\" value=\"A7\">
<span class=\"style1\" >A7</span></span></td>
<td width=\"2%\" bgcolor=\"#ebeae0\" height=\"10\">
<input type=\"text\" name=\"op[unit][]\" size=\"1\" maxlength=\"2\" value =\"$a_unit\"/></td>
<td width=\"32%\" bgcolor=\"#ebeae0\" class=\"style11\">Intermediate</td>\n";
echo "</tr>\n";
echo "</table>\n";
return $op;
}
?>
<?php
[B] /**---------common_list_process.php-----------**/[/B]
echo '<pre>',print_r ($_POST, TRUE), '</pre>';//check array values
//filter array
if(is_array($_POST['wohip']))
{
$fee_code = array_filter($_POST['wohip']);
}
else
{
$fee_code = array($_POST['wohip']);
$fee_code = array_filter($_POST['wohip']);
}
//loop to insert values into database
for($row = 0; $row < 3; $row++)
{
while(list($choice, $unit, $fee_money) = each($fee_code[$row]))
{
$choice; $unit";
}
/**** insert code goes here *****/
}
?>
/** -------------------results of page submission--------------------***/
[op] => Array
(
[unit] => Array
(
[0] =>
[1] =>
[2] => 3
[3] =>
[145] =>
[146] =>
)
[choice] => Array
(
[0] => A8
)
)
Warning: Variable passed to each() is not an array or object in D:\web_server\webroot\common_list_process.php on line