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:
And I'm sending another GET of a filter I'm doing, and it's replacing the current get getting like this
The question is, would I have some way to add the filter GET on the top one after the ID? For example:
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>