4
How could I make a filter like that from the example image?
The part the tables with the data and SELECT
to fetch is quiet. What I’m suffering from is how to build PHP code for this, maybe someone has a way for me to learn how to make these filters.
I’m learning this language yet, I’ve searched on this subject but I haven’t found anything very enlightening, especially something that helps in the first steps.
ESTRUTURA DO BANCO:
TABELA ATIVIDADES
-COD_ATIVIDADE
-CODOPERADOR_ATIVIDADE
-NOME_ATIVIDADE
-DATAINICIO_ATIVIDADE
-DATAFIM_ATIVIDADE
-STATUS_ATIVIDADE
TABELA OPERADORES
-COD_OPERADOR
-NOME_OPERADOR
**EXEMPLO DE CÓDIGO DE RESULTADO:**
<?php
session_start();
$Act = $_GET['act'];
if(isset($Act)){
if($Act == "filtraratv"){
$status = trim($_POST['STATUS_ATIVIDADE']);
$operador = trim($_POST['CODOPERADOR_ATIVIDADE']);
$dataini = $_POST['DATAINICIO_ATIVIDADE'];
$datafim = ($_POST['DATAFIM_ATIVIDADE']);
if(file_exists("../../config.php")) {
require "../../config.php";
} else {
echo "Arquivo config.php nao foi encontrado";
exit;
}
if(!function_exists("Abre_Conexao")) {
echo "Erro o arquivo config.php foi auterado, nao existe a função Abre_Conexao";
exit;
}
Abre_Conexao();
$busca = mysql_query("select * from atividades WHERE status_atividade ='$status'");
$row = mysql_num_rows($busca);
if ($row==0) {
echo "Não há dados";
}
else {
wwhile($l = mysql_fetch_array($busca)) {
$status = $l["STATUS_ATIVIDADE"];
echo "<option value=\"$status\">STATUS: $status</option>\n";
}
}
}
}
?>
NOTE: RETURN CODE: When it executes with some condition (Filter) that does not satisfy the search is displaying the message that has been displayed:"No results found with these criteria", but when it executes a search that exists result, only a blank page appears...
It would be good to put the mysql database structure
– Andrei Coelho
I just put the tables and main fields.. In the example filter could also have the field ACTIVITY NAME.
– TiagoIB
Managed to make?
– Sr. André Baill
What you tried to do?
– Jorge B.
I couldn’t do it, but I’ll turn around here. And when I found out I set the example here in case someone needs it, not to be on hand!
– TiagoIB
It is very easy to do this, just elaborate an SQL for display. With SQL you can do the rest?
– Sr. André Baill
@Tiagoib Posted an answer, see if it meets your need.
– Sr. André Baill
@Andrébaill posted the Return Code for the filters, and even then it doesn’t work (Returns blank page or the message that no result was found), give a look.
– TiagoIB
@Andrébaill This way is very wrong? My last attempt, if not I will try to research other ways.
– TiagoIB