title: Match the number of inserted field with dynamically inserted text boxes
body: <p>book.php   </p>
  
  <pre><code>&lt;input type="text" id="total_seats" name="total_seats" value="" readonly /&gt;&lt;/td&gt;
  </code></pre>
  
  <p>view.php</p>
  
  <pre><code>&lt;?php
     $serial_no = 1;
  $seats = explode(',', $_SESSION['total_seats']);
  foreach ($seats as $seat) { ?&gt;
  &lt;tr&gt;
      &lt;td&gt; &lt;?php echo $serial_no++; ?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?php echo $seat; ?&gt; &lt;/td&gt;
             &lt;td&gt;&lt;input type="text" name="passenger_name[]" style="border:1px solid #000;" required /&gt;&lt;/td&gt;
  
          &lt;/tr&gt;
  </code></pre>
  
  
  
  <p>In book.php page, the total_seats contains the number of seats inserted through checkboxes,  this code runs totally fine but when i check 3 check boxes &amp; the total_seats contain 3 seat numbers, its showing 4 text fields along with serial number upto 4 in my view.php page.. how do i match my seat number with my input total_seats without one extra field ..</p>
  
  <p>Thanks in advance.</p>