Problem passing the correct value in ID to another page
<p>I am using a form to edit comments and using the hidden input fields to pass the value, </p>

<p>the form is something like this.</p>

<pre><code>&lt;input type="text" name="name" value="&lt;?php echo $name; ?&gt;" class="input" /&gt;
&lt;input type="hidden" name="com_name" value="&lt;?php echo $name;?&gt;"/&gt;
&lt;input type="text" name="email" value="&lt;?php echo $email; ?&gt;" class="input" /&gt;
&lt;input type="hidden" name="com_email" value="&lt;?php echo $email;?&gt;"/&gt;
&lt;input type="text" name="phone" value="&lt;?php echo $phone; ?&gt;" class="input" /&gt;
&lt;input type="hidden" name="com_phone" value="&lt;?php echo $phone;?&gt;"/&gt;
&lt;input type="text" name="location" value="&lt;?php echo $location; ?&gt;" class="input" /&gt;
&lt;input type="hidden" name="com_location" value="&lt;?php echo $location;?&gt;"/&gt;
&lt;input type="hidden" name="com_id" value="&lt;?php echo $id; ?&gt;"/&gt;
&lt;textarea name="comment" cols="" rows="" class="comment-msg"&gt;&lt;?php echo $comment; ?&gt;
&lt;/textarea&gt;
&lt;input type="hidden" name="com_comment" value="&lt;?php echo $comment;?&gt;"/&gt;
&lt;input name="com_update_1" type="submit" class="btn-70" value="" /&gt;      
</code></pre>

<p>and i am using the while loop to iterate the value in the form fields. my while loop code is</p>

<pre><code>$query = "SELECT comments.*,
                news.title 
                FROM comments JOIN news ON comments.news_id = news.id
                ORDER BY id DESC LIMIT $from, " . COMM_POST_NUMBER;
      $result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
      $id = $row['id'];
      $date = date("d-F-Y", $row['timestamp']);
      $name = stripslashes($row['name']);
      $email = stripslashes($row['email']);
      $phone = stripslashes($row['phone']);
      $location = stripslashes($row['location']);
      $comment = stripslashes($row['comment']);
      $news_id = $row['news_id'];
      $title = stripslashes($row['title']);
      $approve = $row['approve'];
</code></pre>

<p>The Iteration works well and it prints the value from the database perfectly and the hidden input field with value ID holds the correct value in this page i.e(comments.php). but when i want to pass the value to different page <code>&lt;form action="action.php" method="post"&gt;</code>  my trouble starts it takes only the first id when i hit submit. i.e id with value 1 and it refuses to take any other values from id.</p>

<p>Here is the code from the view source code of the browser</p>

<pre><code>&lt;div class="comments-toggle"&gt;
 &lt;input type="text" name="name" value="My Name is 16" class="input" /&gt;
 &lt;input type="hidden" name="com_name" value="My Name is 16"/&gt;
 &lt;input type="text" name="email" value="check@email.com" class="input" /&gt;
 &lt;input type="hidden" name="com_email" value="check@email.com"/&gt;
 &lt;input type="text" name="phone" value="919999999999" class="input" /&gt;
 &lt;input type="hidden" name="com_phone" value="919999999999"/&gt;
 &lt;input type="text" name="location" value="Somewhere" class="input" /&gt;
 &lt;input type="hidden" name="com_location" value="Somewhere"/&gt;
 &lt;input type="hidden" name="com_id" value="16"/&gt;
 &lt;textarea name="comment" cols="" rows=""class="comment-msg"&gt;                              
&lt;/textarea&gt;
 &lt;input type="hidden" name="com_comment" value=""/&gt;
  &lt;input name="com_update" type="submit" class="btn-70" value="" /&gt;                        
   &lt;/div&gt;
</code></pre>

<p>here is the code from action.php</p>

<pre><code> if( isset($_POST['com_update'])) {
        echo $id = $_POST['com_id'];
    if( isset($_POST['name'])) {
        echo $name = htmlspecialchars(strip_tags(mysql_real_escape_string($_POST['name']))); 
        $query = "UPDATE comments SET name = '$name' WHERE id = '$id'";
        $result = mysql_query($query) or die('Error');
        }
</code></pre>

<p>how do i make it pass the correct id values to action.php?</p>
