It is calling only an if option.
1 => all users per data = if user is empty and data is filled (only this one is calling msm so a user has to be selected, which is wrong the user had to be empty)
2 = > user by date = user filled and date filled
3 => the user = user is filled in and date is empty. Everything else does not return anything.
The code is like this now:
if (isset($_POST['busca']) && !empty($_POST['busca'])){
//todos usuarios por periodo
$sql = "SELECT * FROM assentamentos a, usuarios u, ocorrencias o, problemas p, localizacao l, instituicao i, sistemas s WHERE o.data_abertura BETWEEN '$ymdinicio' AND '$ymdfim' and a.responsavel = u.user_id and a.data = o.data_fechamento and p.prob_id = o.problema and o.local = l.loc_id and i.inst_cod = o.instituicao and s.sis_id = o.sistema ORDER BY o.numero DESC";
}
else if(isset($_POST['data_inicial']) && !empty($_POST['data_inicial']) and isset($_POST['data_final']) && !empty($_POST['data_final'])){
//so usuario
$sql = "SELECT * FROM assentamentos a, usuarios u, ocorrencias o, problemas p, localizacao l, instituicao i, sistemas s WHERE u.nome = '$busca' and a.responsavel = u.user_id and a.data = o.data_fechamento and p.prob_id = o.problema and o.local = l.loc_id and i.inst_cod = o.instituicao and s.sis_id = o.sistema ORDER BY o.numero DESC";
}
else{
//usuario por periodo
$sql = "SELECT * FROM assentamentos a, usuarios u, ocorrencias o, problemas p, localizacao l, instituicao i, sistemas s WHERE o.data_abertura BETWEEN '$ymdinicio' AND '$ymdfim' and u.nome = '$busca' and a.responsavel = u.user_id and a.data = o.data_fechamento and p.prob_id = o.problema and o.local = l.loc_id and i.inst_cod = o.instituicao and s.sis_id = o.sistema ORDER BY o.numero DESC";
}
print "<table width='100%' border='0' align='center' cellpadding='1' cellspacing='2' class='full_table_list'>";
print "<tr class='tabela_cinza'>";
print "<td align='center' colspan='10'><span class='texto_negrito'>Relatório Geral</span></td>";
print "</tr>";
print "<tr>";
print "<td align='center' width='8%'><span class='texto_negrito'>Número</span></td>";
print "<td align='center' width='8%'><span class='texto_negrito'>Técnico</span></td>";
print "<td align='center' width='8%'><span class='texto_negrito'>Problema</span></td>";
print "<td align='center' width='16%'><span class='texto_negrito'>Descriçao do problema</span></td>";
print "<td align='center' width='16%'><span class='texto_negrito'>Soluçao do Problema</span></td>";
print "<td align='center' width='8%'><span class='texto_negrito'>Área</span></td>";
print "<td align='center' width='8%'><span class='texto_negrito'>Unidade</span></td>";
print "<td align='center' width='12%'><span class='texto_negrito'>Local</span></td>";
print "<td align='center' width='8%'><span class='texto_negrito'>Data inicial</span></td>";
print "<td align='center' width='8%'><span class='texto_negrito'>Data final</span></td>";
print "</tr>";
print "</table>";
$qr = mysql_query($sql) or die(mysql_error());
while ($linha = mysql_fetch_array($qr)) {
print "<form action='' method='post' name='CadInfo' target='_parent' id='CadInfo'>";
print "<table width='100%' border='0' align='center' cellpadding='1' cellspacing='2' class='full_table_list'>";
print "<tr>";
print "<td align='center' width='8%'><span class='texto_center'>".$linha['numero']."</span></td>";
print "<td align='center' width='8%'><span class='texto_center'>".$linha['nome']."</span></td>";
print "<td align='center' width='8%'><span class='texto_center'>".$linha['problema']."</span></td>";
print "<td align='center' width='16%'><span class='texto_center'>".$linha['descricao']."</span></td>";
print "<td align='center' width='16%'><span class='texto_center'>".$linha['assentamento']."</span></td>";
print "<td align='center' width='8%'><span class='texto_center'>".$linha['sistema']."</span></td>";
print "<td align='center' width='8%'><span class='texto_center'>".$linha['inst_nome']."</span></td>";
print "<td align='center' width='12%'><span class='texto_center'>".$linha['local']."</span></td>";
print "<td align='center' width='8%'><span class='texto_center'>".$linha['data_abertura']."</span></td>";
print "<td align='center' width='8%'><span class='texto_center'>".$linha['data_fechamento']."</span></td>";
print "</tr>";
print "</table>";
print "</form>";
}
A great weekend at all.