I've looked at your code. This code will produce the following output in the web browser.
<form action="mytest2.php" method="post">
<input type="text" name="myar[1]" value=""size="8">
</form>
<form action="mytest2.php" method="post">
<input type="text" name="myar[2]" value="" size="8">
</form>
<form action="mytest2.php" method="post">
<input type="text" name="myar[3]" value="" size="8">
</form>
<form action="mytest2.php" method="post">
<input type="text" name="myar[4]" value="" size="8">
</form>
<form action="mytest2.php" method="post">
<input type="hidden" name="myar[1]" value="">
<input type="hidden" name="myar[2]" value="">
<input type="hidden" name="myar[3]" value="">
<input type="hidden" name="myar[4]" value="">
As you can see there are several forms. When a form is submitted only the input conatined inside that form tag will be sent to you script.
All you need to do is move all your input variables into the same form tag. I have corrected the code for you and also inserted a submit button:
<?php
$items = 5;
// This is where i have read the data from my db
// have left that out in this example
$myar = array("item1", "item2", "item3", "item4", "item5");
// open the form tag
echo ("<form action=\"mytest2.php\" method=\"post\">\n");
for($counter = 1; $counter<$items; $counter++): ?>
<input type="text" name="<?php echo($myar[$counter])?>" value="<?php echo ($myar[$counter])?>" size="8">
<input type="hidden" name="<?php echo ($myar[$counter]) ?>" value="<?php echo($myar[$counter])?>">
<?php endfor;
// close the insert a submit button and close the form tag
echo (" <input type=\"submit\">\n</form>");
?>
This code produces the following output when viewed in the web browser:
<form action="mytest2.php" method="post">
<input type="text" name="item2" value="item2" size="8">
<input type="hidden" name="item2" value="item2">
<input type="text" name="item3" value="item3" size="8">
<input type="hidden" name="item3" value="item3">
<input type="text" name="item4" value="item4" size="8">
<input type="hidden" name="item4" value="item4">
<input type="text" name="item5" value="item5" size="8">
<input type="hidden" name="item5" value="item5">
<input type="submit">
</form>
Noticed I escaped PHP in the for loop. I think this looks neater and more readable. But it is optional.
Hope this is of some help. Adam