Ok for each field you have, you'll need to make it an array. For firstname, set it as "firstnames[$row[id]]" and lastname, "lastnames[$row[id]]" so you end up submitting each piece of data tied to the user.
When you receive the data, you loop through one of the arrays (all should have the same "keys" [ids] so it doesn't matter which field you choose).
Inside the loop, you'll have to grab the other fields
PHP Code:
foreach ($_POST['firstnames'] as $userid => $firstname)
{
$lastname = $_POST['lastnames'][$userid];
$email = $_POST['emails'][$userid];
// update query
}