Retrieve data from dynamically generated form
<p>I'm trying to use a dynamically created form to edit content on a page. I retrieve information from a DB table (in this case image captions) and display them in text areas ready to be edited and saved back into the DB.</p>

<p>This seems to do the job of organizing and displaying the form:</p>

<pre><code>echo"&lt;form action='edit.php' method='post'&gt;";
 for ($limit;$limit&lt;=$all_values;$limit++)
     {
      echo "&lt;textarea cols='15' rows='3' name='caption' value='$caption_arr[$limit]'&gt;
             $caption_arr[$limit]&lt;/textarea&gt;&lt;br&gt;
      }
      echo "&lt;br&gt;&lt;input type='submit' value='Edit' name='pictureEedit'&gt;&lt;/form&gt;";
</code></pre>

<p>But something goes wrong from here. When I enter this in edit.php:</p>

<pre><code> $caption=$_POST['caption'];
 echo $caption;
</code></pre>

<p>And I only get the caption from the last field. When I added check boxes to the form it all worked fine provided I only checked 1 but if I checked 2 or more it would only give me the value for the last one.</p>

<p>I also tried this:</p>

<pre><code> $caption[$x]=$_POST['caption'];
 foreach ($caption as $key =&gt; $value) {echo $key.$value.'&lt;br&gt;';}
</code></pre>

<p>but got the same result.</p>
