I have a code where you would have a select to select in which column you want to search and click on the letter to fetch within the selected column the selected letter.
The error is on my button. It would have to be <a href="">
only that by having a <form action="">
directed to another page href
conflicts with form
Search code letter "A":
require_once 'functions.php';
$PDO = db_connect();
$opcao_filtro = filter_input(INPUT_POST, 'opcao_filtro', FILTER_SANITIZE_STRING);
$sql = 'SELECT * FROM tablet AS t WHERE';
//idlivro, titulo, tipo, e cor.
switch($opcao_filtro)
{
switch($opcao_filtro)
{
case 'titulo': {
$sql .= ' t.titulo like "a%"';
break;
}
case 'cor': {
$sql .= ' t.cor like "a%"';
break;
}
case 'categoria': {
$sql .= ' t.categoria like "a%"';
break;
}
}
$stmt = $PDO->prepare($sql);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$result = array_unique($rows);
foreach($rows as $row)
{
echo $row['titulo'];
echo $row['cor'];
echo $row['categoria'];
}
Button Tag:
<button type="submit" class="btn btn-link btn-xs" value="a" name="a">A</button>
Select:
<div class="op">
<select name="opcao_filtro" class="form-control" style="width:150px; height:30px;">
<option value="nulo">---</option>
<option value="titulo">Título</option>
<option value="autor">Autor</option>
<option value="tema">Tema</option>
<option value="editora">Editora</option>
</select>
</div>