title: Update data in table row [PHP]
body: <p>I have a standard HTML table, each row in the table is generated from a database table using a loop.</p>
  
  <p>At the end of each row I have an update button, I'd like this to update data in the table fields.</p>
  
  <p>The image below shows the concept.</p>
  
  <p><a href="https://i.stack.imgur.com/iPRoR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iPRoR.jpg" alt="enter image description here"></a></p>
  
  <p>The table itself</p>
  
  <pre><code>&lt;div class="container" id="users"&gt;
  
      &lt;div class="row"&gt;
       &lt;div class="col-md-12"&gt;
        &lt;div class="table-responsive"&gt;
  
          &lt;form method="post" action=""&gt;
  
              &lt;table class="table table-bordered table-hover table-striped tablesorter"&gt;
               &lt;thead&gt;
  
                  &lt;tr&gt;
  
                   &lt;th width="10%" style="text-align:left"&gt;Forename&lt;/th&gt;
                   &lt;th width="15%" style="text-align:left"&gt;Surname&lt;/th&gt;
                   &lt;th width="35%" style="text-align:left"&gt;Email&lt;/th&gt;
                   &lt;th width="30%" style="text-align:left"&gt;Permissions&lt;/th&gt;
                   &lt;th width="5%" style="text-align:left"&gt;Update&lt;/th&gt;
                   &lt;th width="5%" style="text-align:left"&gt;Delete&lt;/th&gt;
  
                 &lt;/tr&gt;
               &lt;/thead&gt;
              &lt;tbody&gt;
                 &lt;tr&gt;
                  &lt;!--here showing results in the table --&gt;
              &lt;?php  
  
                   $adminquery = "SELECT * FROM admin ORDER by user_id DESC";  
                   $IDlist = mysqli_query($dbconEDB, $adminquery);
  
                   while($rowlist=mysqli_fetch_array($IDlist))//while look to fetch the result and store in a array $row.  
                          { 
                          $user_id = $rowlist["user_id"]; 
                          $admin_email = $rowlist["admin_email"]; 
                          $forename = $rowlist["forename"];
                          $surname = $rowlist["surname"];
  
                          $JPortal = $rowlist["JPortal"];
                          $Tenders = $rowlist["Tenders"];
                          $News= $rowlist["News"];
                          $Events = $rowlist["Events"];
                          $Users= $rowlist["Users="] ;
  
                             ?&gt;
  
                      &lt;td style="text-align:left"&gt;
                       &lt;div class="form-group"&gt;
                        &lt;input name="user_id" id="user_id" type="text"  class="form-control" value="&lt;?php echo $user_id;?&gt;"&gt;
                        &lt;input name="forename" id="forename" type="text"  class="form-control" value="&lt;?php echo $forename;?&gt;"&gt;
                        &lt;div class="hidden"&gt;  &lt;?php echo $forename;?&gt;&lt;/div&gt;
                       &lt;/div&gt;
                      &lt;/td&gt;
  
                      &lt;td style="text-align:left"&gt;
                        &lt;div class="form-group"&gt;
                          &lt;input name="forename" id="surname" type="text"  class="form-control" value="&lt;?php echo $surname;?&gt;"&gt;
                           &lt;div class="hidden"&gt;  &lt;?php echo  $surname;?&gt;&lt;/div&gt;
                        &lt;/div&gt;
                      &lt;/td&gt;
  
                      &lt;td style="text-align:center"&gt;
                       &lt;div class="form-group"&gt;
                         &lt;input name="admin_email" id="admin_email" type="text"  class="form-control" value="&lt;?php echo $admin_email;?&gt;"&gt;
                         &lt;div class="hidden"&gt;  &lt;?php echo  $admin_email;?&gt;&lt;/div&gt;
                       &lt;/div&gt;
                      &lt;/td&gt;
  
                    &lt;td style="text-align:center"&gt;
  
  
                          &lt;label&gt;
                            &lt;input name="JPortal" type="checkbox" id="JPortal"   value="1" &lt;?php if ($JPortal == 1) echo "checked='checked'" ;?&gt;&gt; Jobs 
                          &lt;/label&gt;
  
                          &lt;label&gt;
                           &lt;input type="checkbox" name="Tenders" value="1" id="Tenders"   &lt;?php if ($Tenders == 1) echo "checked='checked'" ;?&gt;&gt; News 
                          &lt;/label&gt;
  
                          &lt;label&gt;
                           &lt;input type="checkbox" name="News" value="1" id="News"   &lt;?php if ($News == 1) echo "checked='checked'" ;?&gt;&gt; Tenders 
                          &lt;/label&gt;
  
                          &lt;label&gt;
                           &lt;input type="checkbox" name="Events" value="1" id="Events"  &lt;?php if ($Events == 1) echo "checked='checked'" ;?&gt;&gt; Events 
                          &lt;/label&gt;
  
                          &lt;label&gt;
                           &lt;input type="checkbox" name="Users" value="1" id="Users"   &lt;?php if ($Users == 1) echo "checked='checked'" ;?&gt;&gt; Users 
                          &lt;/label&gt;
  
  
                     &lt;/td&gt;                
  
                    &lt;td style="text-align:center"&gt;
  
                          &lt;input class="btn btn-newable " type="submit" value="Update" name="EDBsubmit"&gt;
                    &lt;/td&gt;
  
                    &lt;td style="text-align:center"&gt;
                       &lt;a href="users.php?user=&lt;?php echo $user_id; ?&gt;"&gt;&lt;button class="btn btn-newable"&gt;update2&lt;/button&gt;&lt;/a&gt;
                    &lt;/td&gt;
  
              &lt;/tr&gt;
                          &lt;?php } ?&gt;
  
                &lt;/tbody&gt;
              &lt;/table&gt;
  
           &lt;/form&gt;
  
         &lt;/div&gt;
        &lt;/div&gt;
  
      &lt;/div&gt;
  </code></pre>
  
  <p>I'm thinking I've just had an off day and could of in fact wrapped the form around each row of the table.</p>