Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从动态php列表中的用户获取id_Php_Mysql_Pdo - Fatal编程技术网

从动态php列表中的用户获取id

从动态php列表中的用户获取id,php,mysql,pdo,Php,Mysql,Pdo,我目前正在进行一个可以添加用户的项目,我有一个视图,其中显示了我的动态用户列表: 当我单击管理删除功能的Effacer按钮时,我希望能够将该行用户的电子邮件发送给我的控制器,但它总是将第一行用户发送到此处nba@gmail.com. 我如何做到这一点?它以会话或任何其他方式存储,每次都存储正确的用户电子邮件 视图: <div class="mx-auto mt-3" style="width: 500px;"> <!-- form to

我目前正在进行一个可以添加用户的项目,我有一个视图,其中显示了我的动态用户列表:

当我单击管理删除功能的Effacer按钮时,我希望能够将该行用户的电子邮件发送给我的控制器,但它总是将第一行用户发送到此处nba@gmail.com.

我如何做到这一点?它以会话或任何其他方式存储,每次都存储正确的用户电子邮件

视图:

<div class="mx-auto mt-3" style="width: 500px;">
<!-- form to delete -->
<form action="../ressources/deleteuser.php" method="post">
    <h3>Liste des utilisateurs enregistrés</h3>

    <table class="table">
  <thead>
    <tr>
      <th scope="col">#</th>
      <th scope="col">Nom</th>
      <th scope="col">email</th>
      <th scope="col">type de compte</th>
    </tr>
  </thead>
  <tbody>
    <?php
        include('../ressources/listusers.php');
    ?>
  </tbody>
</table>
</form>
</div> 
我的控制器:

$sql = "SELECT * FROM  userlogin";

$users = $DBH->query($sql);

//compteur
$i=0;

foreach($users as $user)
{
    $i++;
    
    echo('<tr>
    <th scope="row">');
    echo($i);
    echo('</th>');
    echo('<td>');
    echo($user['name']);
    echo('</td>');

    echo('<td>');
    echo($user['email']);
    echo('</td>');

    echo('<td>');
    echo($user['type']);

    $_SESSION['email']=$user['email'];
    echo('</td>');

    if($_SESSION['type'] == "admin")
    {
        echo('<td>');
        echo('<button type="submit" class="btn btn-danger">Effacer</button>');
        echo('</td>');
    
        echo('</tr>');
    }
   
    
}