title: How to update the database. After adding data from the database to the form
body: <p>How to update the database. I will not add new records. 
  The data is identical to the code retrieved from the database. I do not know how
  to embed the second function, from the form and update the database.
  reading from the database to the form works  </p>
  
  <pre><code>&lt;form action="" method="put"&gt;
    &lt;table width="100%"&gt;
     &lt;thead&gt;
      &lt;tr&gt;
        &lt;td class="colsp" colspan="5"&gt;Terminarz&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr class="subcolor title-row"&gt;
        &lt;td style="width: 10%"&gt;id&lt;/td&gt;
        &lt;td style="width: 40%" class="left"&gt;Gospodarz&lt;/td&gt;
        &lt;td style="width: 40%"&gt;Gość&lt;/td&gt;
        &lt;td style="width: 5%"&gt;Home&lt;br/&gt;Goals&lt;/td&gt;
        &lt;td style="width: 5%"&gt;Guest&lt;br/&gt;Goals&lt;/td&gt;
     &lt;/tr&gt;
        &lt;/thead&gt;
      &lt;tbody&gt;
  &lt;?php
  if(isset($_POST['Submit'])){
      $hGoals = $_POST['inphomegoals'];
      $gGoals = $_POST['inpguestGoals'];
      $update="UPDATE matches SET homeGoals=$hGoals, guestGoals=$gGoals where matchID = ".$matchID;
      $stmt = $conn-&gt;prepare($update);
      $stmt-&gt;execute();
      echo $stmt-&gt;rowCount() . " records UPDATED successfully";
      }
      $display = $conn-&gt;prepare(
                                "SELECT
                                     m.matchID,
                                     hc.clubName as homeClub,
                                     gc.clubName as guestClub,
                                     m.homeGoals,
                                     m.guestGoals
                             FROM matches AS m
                             JOIN clubs AS hc ON hc.clubID = m.homeID
                             JOIN clubs AS gc ON gc.clubID = m.guestID
                             ORDER BY matchID ASC ");
  
  $display-&gt;execute();
  $results = $display-&gt;fetchAll();
  foreach ($results as $index =&gt; $row){
  ?&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;label&gt;&lt;?php echo $row['matchID']; ?&gt;&lt;/label&gt;&lt;/td&gt;
              &lt;td&gt;&lt;label&gt;&lt;?php echo $row['homeClub']; ?&gt;&lt;/label&gt;&lt;/td&gt;
              &lt;td&gt;&lt;label&gt;&lt;?php echo $row['guestClub']; ?&gt;&lt;/label&gt;&lt;/td&gt;
              &lt;td&gt;&lt;label&gt;&lt;input type="number" name="inphomegoals" value="&lt;?php echo $row['homeGoals']; ?&gt;"/&gt; : &lt;/label&gt;&lt;/td&gt;
              &lt;td&gt;&lt;label&gt;&lt;input type="number" name="inpguestGoals" value="&lt;?php echo $row['guestGoals']; ?&gt;"&lt;/label&gt;&lt;/td&gt;
          &lt;/tr&gt;
  &lt;?php } ?&gt;
      &lt;/tbody&gt;    
            &lt;tfoot&gt;
              &lt;tr&gt;
               &lt;td colspan="5"&gt;&lt;input type="submit" value="Add To Base" name="Submit" style="width: 150px; height: 45px"&lt;/td&gt;
              &lt;/tr&gt;
            &lt;/tfoot&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>connect.php</strong></p>
  
  <pre><code>&lt;?php
   $db_server="localhost";
   $db_username="root";
   $db_password="";$db_database="football_db";
   $conn=new
  PDO("mysql:host=$db_server;dbname=$db_database",$db_username, $db_password);  
   $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  ?&gt;
  </code></pre>