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