I have a html form which generates a second html form via $_POST. 
The first form submits $_POST['id'], which will then generate another form that will submit $_POST['fields'] which is used to update a mysql db. However, the mysqli query used to update the db relies on both $_POST['id'] and $_POST['fields'] values. 
I can't work around how to submit $_POST['fields'] without $_POST['id'] being reset, because $_POST['fields'] is generated precisely by the submission of $_POST['id'].
I tried passing $_POST values to $_SESSION, and while the values are passed successfully, the $_POST['id'] value will always reset to NULL once $_POST['fields'] is submitted. Here's the whole code:
<?php 
include 'head.html';
echo "<body>";
include 'connection.php';   
$query = mysqli_query("SELECT * FROM table") or die(mysqli_error());
$querytwo = mysqli_query("SELECT * FROM table WHERE id='{$_POST[id]}'") or die(mysqli_error());
//generates $_POST['id'] form
echo "<form action=\"admin.php\" method=\"post\"><select name=\"id\">";
    while ($row = mysqli_fetch_array($query)) 
    {
        echo "<option value=\"$row[id]\">$row[firstName] $row[lastName]</option>";
    }
echo "</select><input type=\"submit\"></form><br>";
 //generates $_POST['fields'] form
if (isset($_POST['id']) && !empty($_POST['id'])) 
{   
        $rowtwo = mysqli_fetch_array($querytwo);    
        $exclude = array(2);
        for($column_value = 0; $column_value < 17; $column_value++) 
         {
            if (in_array($column_value, $exclude)) 
            {
                continue;
            }
                $field = mysqli_field_name($querytwo, $column_value);
                echo "<form method=\"POST\">" . "$field" . ": <input type=\"text\" name=\"fields\" value=\"$rowtwo[$column_value]\"><input type=\"submit\"></form>";    
        }
}  
 //updates db with $_POST['id'] and $_POST['fields'] values
if (isset($_POST['field']) && !empty($_POST['field']))
{
    $column_value = range(0, 20);
    $field = mysqli_field_name($querytwo, $column_value);
    mysqli_query("UPDATE table SET '$field'='{$_POST[fields]}' where id='{$_POST[id]}'");
} else 
{
 echo "not updated yet";    
}
?>
</body>
</html>
 
     
     
     
     
    