I have a table on my page and the first time it is loaded is when the user enters the page. On my database table I have a BIT and on my page I have two buttons. When I click in the first button I want to show in the table the data with the bit in 0 and in the second button, the data with the bit in 1. I tried creating a function:
$EstadoAtivo = 0;
$EstadoEncerrado = 1;
function updateTable() {
$connect = mysqli_connect("localhost", "user", "password", "dbname")
if($showFirst){
$query = "SELECT * FROM tabela_ordens WHERE Estado = '$EstadoAtivo' ORDER BY Id desc";
}else{
$query = "SELECT * FROM tabela_ordens WHERE Estado = '$EstadoEncerrado' ORDER BY Id desc";
}
$result = mysqli_query($connect, $query);
}
And then when I click the first button I run:
<?php
$showFirst = true;
updateTable();
?>
$("#table-ordens").load('index #table-ordens');
and the second button is the same but $showFirst = false;
And inside my table I have:
<?php
while($row = mysqli_fetch_array($result))
{
?>
<tr>
<td><?php echo $row['ID']; ?></td>
<td><?php echo $row['Cliente']; ?></td>
<td><?php echo $row['Equipamento']; ?> </td>
<td><input type="button" name="view" value="Exibir" id="<?php echo
$row['ID'];?>" class="btn mostrar_info btn-block" />
</td>
<td><input type="button" name="view" value="Encerrar" id="<?php echo $row['ID'];?>" class="btn encerrar_chamado btn-block btn-danger" /></td> </tr>
<?php
}
?>
But it doesn't work, nothing changes when I click my buttons.