更改特定的mysql列

So I've got this code, which changes my type column from a to d in my mysql database. But sadly, it changes even all the other type columns of all the other user ALTHOUGH I specified it with WHERE id_user = X(in the other codes, only the WHERE id_user = X varies like WHERE id_user = 1, WHERE id_user = 2 etc.):

       <td><?php
if(isset($_POST['d'])){
$var2 = $_POST['d'];
$sql = "UPDATE users SET `type`= '$var2'  WHERE id_user = 2 ";
$mysqli->query($sql) or die($mysqli->error);
}
if(isset($_POST['a'])){
$var2 = $_POST['a'];
$sql = "UPDATE users SET `type`= '$var2'  WHERE id_user = 2 ";
$mysqli->query($sql) or die($mysqli->error);

}
?>
<?php

 if ($result = $mysqli->query("SELECT `type` FROM users WHERE id_user = 2 ")) {

    $r = mysqli_fetch_assoc($result);

    }
    echo implode($r);
    echo implode($_POST);
?>
</td>
<td>
<form action="#" method="POST">
   <input type="hidden" value="d" name="d"/>
   <input type="submit" value="--Inaktiv--"/>
</form>
<form action="#" method="POST">
   <input type="hidden" value="a" name="a"/>
   <input type="submit" value=" --Aktiv-- "/>
</form>

Why does this happen and how do I change it the way, only the column of the right user changes? How do I determine the submit button to the specific $sql = "UPDATE users SETtype= '$var2' WHERE id_user = X "; ?