How to add a get without replacing what you already have?

0

I do not know if this is the case, but what I want to do is basically keep the GET parameters that already have on the page, for example it looks like this:

link

And I'm sending another GET of a filter I'm doing, and it's replacing the current get getting like this

link

The question is, would I have some way to add the filter GET on the top one after the ID? For example:

link

My code looks like this:

if (isset($_GET['id']) && !empty($_GET['id'])) {
$idArea = $_GET['id'];
$sqlArea = mysqli_query($conexao, "SELECT nomeArea FROM area WHERE idArea = '$idArea'");
while ($row = mysqli_fetch_array($sqlArea)) {
    $nomeArea = utf8_encode($row['nomeArea']);
}

$ordernar = "posts.dataPost DESC";

// FILTRO
if(isset($_GET['filtro'])){
    $filtro = $_GET['filtro'];
    switch($filtro){
        case ('views'):
            $ordernar = "visualizacoes DESC";
            break;
        case ('autor'):
            $ordernar = "Autor DESC";
            break;
        case ('titulo'):
            $ordernar = "topico.titulo ASC";
            break;
    }
}

<form method="GET" class="form-inline">
        <div class="form-group">
          <label for="listarPor">Listar por:</label>
          <select name="filtro" class="form-control" onchange="this.form.submit()">
              <option>Selecione</option>
              <option value="views">Visualizações</option>
              <option value="autor">Usuário</option>
              <option value="respostas">Respostas</option>
              <option value="titulo">Título</option>
          </select>
        </div>
    </form>
    
asked by anonymous 23.11.2016 / 19:39

1 answer

1

Soon after form , add a hidden field

<form method="GET" class="form-inline">
<input type="hidden" name="id" value="<?php echo $idArea;?>">

The rest remains as it is.

    
23.11.2016 / 19:54