I have a user table where I have to display a delete button and I need to make sure the current user cannot delete themselves.
In order to do that, I wrote some code as shown below, but it doesn't work.
The user table appears with the delete button in all the users, but I need to make sure the current user cannot delete their own user account.
while($row = mysqli_fetch_array($result)) {
$output .='<tr>
<td>'.$row["user_id"].'</td>
<td>'.$row["fullname"].' </td>
<td>'.$row["user_role"].'</td>
<td>'.$row["username"].'</td>
<td>'.$row["password"].'</td>
<td>'.$row["branch_id"].'</td>
<td>'.$row["registered_date"].'</td>
<td>
<button id="'.$row["user_id"].'" class="btn btn-warning btn-xs edit_data"><i class="fa fa-edit "></i></button>
if('.$_SESSION['username'].'!='.$row["username"].') {
<a id="'.$row["user_id"].'" class="btn btn-danger btn-xs delete"><i class="fa fa-times"></i></a> } </td>
</tr>';
}
$output .= '</table>';
echo $output;