I'm trying to send the id to another page
I tried $_SESSION but it just takes the last id and deletes
I'm using the Foreach function
$_SESSION['IDIt'] just takes the last ID and $_GET['IDIt'] doesn't work
<div class="container">
  <div class="table-responsive">
    <h4 class="text-center mt-4">Itenerario</h4>
    <table class="table table-hover">
      <thead>
        <tr>
          <th width="35%">Local</th>
          <th width="15%">Data</th>
          <th width="10%">Custo</th>
          <th width="10%">N Pessoa</th>
          <th width="25%">Opções</th>
        </tr>
      </thead>
      <tbody>
        <?php
          foreach($resultado as $registo){ ?>
          <tr>
            <td>
              <?php echo $registo["Local"] ?>
            </td>
            <td>
              <?php echo $registo["Data"] ?>
            </td>
            <td>
              <?php echo $registo["Custo"] ?>
            </td>
            <td>
              <?php echo $registo["Pessoa"] ?>
            </td>
            <td>
              <a class="btn btn-sm btn-danger" href="eliminar.php?id=<?php echo $registo[" IDIt "]; ?>">Eliminar</a>
              <a class="btn btn-sm btn-success" href="#">Editar</a>
            </td>
          </tr>
          <?php }  ?>
          <?php
            $_SESSION['IDIt'] = $registo["IDIt"];
          ?>
      </tbody>
    </table>
  </div>
</div>
Eliminar.php
<?php 
    session_start();
    include 'conexao.php';
    if (isset($_SESSION['IDIt'])) {
        $id = $_SESSION['IDIt'];
    //$query = ("DELETE * from reserva_it where IDIt = $id");
    $sql ="DELETE from reserva_it Where IDIt like '$id'";
    $result = mysqli_query($conexao, $sql);
    echo 'O Reserva com o id = '; echo $id; echo ' foi apagado';
    }else{
        echo 'erro';
    }
?>
 
     
    