在另一个循环中保存一次复选框值

I have this code:

<?php
if(isset($_POST['submit'])) {
 if(isset($_POST['sharks'])) {
      $_SESSION['value'] = $_POST['sharks'];
  } else {
      $_SESSION['value'] = '';
  }
}
?>
<form action="" method="POST">
  <?php
  echo '<input name="sharks" type="checkbox" value="1" id="sharks" ';
    if ($_SESSION['value'] == 1) {
      echo ' checked="checked"';
    }
  echo ">";
  ?>
  <br>
  <button type="submit" name="submit" value="Save">Salva</button>
</form>

I'm already inside a loop of users, I just want to add a checkbox next to them and save the value of that checkbox connected to that user.
enter image description here

When I try to save the checkbox this is what happen:
enter image description here

Thank you all

UPDATE: This image can help a lot: https://i.imgur.com/vXjSqcF.png
This is the table I have, I just want to add a checkbox next to every user and save the status of them.

It's hard to make an answer based on assumption. I assume that your field names are identical. In general, in case of identical input names either all values shall be checked at once when you select one or only one value shall be checked based on conditional submit. This is usual as you are not defining unique input names for the users. However, In order to select as much users as you need follow the code structure below:

<?php
if(isset($_POST['submit'])){ $_SESSION['mysession'] = $_POST; }else{ $_SESSION['mysession'] = array('user1'=>'', 'user2'=>'', 'user2'=>'', 'user3'=>'');}
?>

<form action="<?php echo $_SERVER["PHP_SELF"];?>" method="POST"> 
<input type="checkbox" name="user1" value="1" <?php if (isset($_POST['user1'])){ echo "checked";}?> > 
<input type="checkbox" name="user2" value="2" <?php if (isset($_POST['user2'])){ echo "checked";}?> > 
<input type="checkbox" name="user3" value="3" <?php if (isset($_POST['user3'])){ echo "checked";}?> > 
<button type="submit" name="submit" value="Save">Try</button>
</form>
 
<?php var_dump($_SESSION['mysession']); ?>

If you need to insert the value 1 into database for all users just change the value to value="1" for every check box input.

So you don't not need separate save button for every check box. I hope that you shall definitely get the desired output.

</div>

This is can help you basically:

<?php

$selected_attribute = $_SESSION['value'] == 1 ? "checked" : "";
echo("<input name='sharks' type='checkbox' value='1' id='sharks' ".$selected_attribute.">");

?>

Tried improving/cleaning your code a bit:

<?php if(isset($_POST['submit'], $_POST['sharks'])) {
    $_SESSION['value'] = $_POST['sharks'];
} else {
    $_SESSION['value'] = '';
} ?>

<form action="" method="POST">

    <input name="sharks" type="checkbox" value="1" id="sharks" <?php echo $_SESSION['value'] == 1 ? "checked" : ""; ?>
    <br>
    <button type="submit" name="submit" value="Save">Salva</button>
</form>

This should work.