RE: passing array values in forms
| From: | Mignon Hunter | Date: | Mon, 06 Jan 2003 16:23:28 +0000 |
| Subject: | RE: passing array values in forms | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-24594@lists.php.net to get a copy of this message | ||
This is a variation to similar string earlier. Have been checking
books, online manuals, suggestions here - tutorials and such.
Having issues passing arrays in forms. I have been working on this a few
days and am stuck. Am trying to pass cat[] and id[] with whatever
checkbox user checks. cat[] works fine. My id[] is hidden and am not
able to pass correctly. cat[] will display correct item on second page
but idid[] just passes 12 (which is the number of initial items in the
result from query) - or it will display 1,2,3,4,5,6,7,8,9,10,11.
Does anyone have suggestions. I have tried using submit hidden value
among other variations...to no avail.
Thx
Mignon
<CODE BEGINS>
page1.php snipet
<form action="comp_page4.php" method="post">
<?
for($knt = 0;$row = mysql_fetch_row($res); $knt++)
{
echo "<tr><td><input type=\"checkbox\" name=\"cat[]\" value
=
$row[1]></td><td> $row[1]</td><td>$row[2].</td></tr>";
echo "<input type = \"hidden\" name = \"id[]\" value =
$row[0]>";
}
?>
<input type="submit" value="Next">
</form>
comp_page4.php snipet
<?
echo "Hello cat[0] and cat[1] ect...: $cat[0], $cat[1], $cat[2],
$cat[3], $cat[4], $cat[5], $cat[6], $cat[7], $cat[8], $cat[9], $cat[10],
$cat[11]<br>";
echo "<br>";
echo "Here's id: $id[0], $id[1], $id[2], $id[3], $id[4], $id[5],
$id[6], $id[7], $id[8], $id[9], $id[10], $id[11]";
?>
<CODE ENDS>