Help with passing arrays between php scripts
Posted: Fri Sep 20, 2002 8:25 am
Can anybody put me on the right track on how to pass arrays between php scripts.
I thought it would be something like:
$preselectvar = array();
echo '<form action="test.php" method="post">';
echo ' <table border=0>';
echo ' <input type="hidden" name="preselectvar[]" value="'.$preselectvar.'">';
for ($i=0; $i< $num_results; $i++)
{
echo ' <tr>';
$row = mysql_fetch_array($result);
$name = htmlspecialchars(stripslashes($row["Variable"]));
$units= htmlspecialchars(stripslashes($row["Units"]));
$preselectvar[]=$name;
echo ' <td>'.$name.'</td>';
echo ' <td> <select name="constraint[]">';
echo ' <option value="*" selected>*';
echo ' <option value="=">=';
echo ' <option value=">">>';
echo ' <option value="<"><';
echo ' <option value=">=">>=';
echo ' <option value="<="><=';
echo ' </select></td>';
echo ' <td><input type=text maxlength=10 size=10 name="value['.$i.']"</td>';
echo ' <td>'.$units.'</td>';
echo ' </tr>';
}
echo ' </table>';
echo ' <table border=0>';
echo ' <tr>';
echo ' <td colspan=2><input type=submit value="Submit">';
echo ' <input type=reset value="Reset"></td>';
echo ' </tr>';
echo ' </table>';
echo '</form>';
?>
and that I can use the two arrays in test.php with:
$constraint=$_POST("constraint");
$preselectvar=$_POST("preselectvar");
But this doesn't work in either case.
So where do I look, or what is the solution ???
thanx in advance
I thought it would be something like:
$preselectvar = array();
echo '<form action="test.php" method="post">';
echo ' <table border=0>';
echo ' <input type="hidden" name="preselectvar[]" value="'.$preselectvar.'">';
for ($i=0; $i< $num_results; $i++)
{
echo ' <tr>';
$row = mysql_fetch_array($result);
$name = htmlspecialchars(stripslashes($row["Variable"]));
$units= htmlspecialchars(stripslashes($row["Units"]));
$preselectvar[]=$name;
echo ' <td>'.$name.'</td>';
echo ' <td> <select name="constraint[]">';
echo ' <option value="*" selected>*';
echo ' <option value="=">=';
echo ' <option value=">">>';
echo ' <option value="<"><';
echo ' <option value=">=">>=';
echo ' <option value="<="><=';
echo ' </select></td>';
echo ' <td><input type=text maxlength=10 size=10 name="value['.$i.']"</td>';
echo ' <td>'.$units.'</td>';
echo ' </tr>';
}
echo ' </table>';
echo ' <table border=0>';
echo ' <tr>';
echo ' <td colspan=2><input type=submit value="Submit">';
echo ' <input type=reset value="Reset"></td>';
echo ' </tr>';
echo ' </table>';
echo '</form>';
?>
and that I can use the two arrays in test.php with:
$constraint=$_POST("constraint");
$preselectvar=$_POST("preselectvar");
But this doesn't work in either case.
So where do I look, or what is the solution ???
thanx in advance