Ir para conteúdo
Fórum Script Brasil
  • 0

SCRIPT DE BUSCA EM SITE DE IMOBILIÁRIA VALOR MÁXIMO NÃO RETORNA NENHUM


leandrodorio

Pergunta

Bom dia Galera... estou aqui quebrando cabeça, com o scritp de busca onde quando se coloca o valor máximo em uma busca ele não retorna nenhum resultado... SERÁ QUE ALGUÉM PODERÁ ME DAR UMA LUZ??? Segue abaixo o script

<?php
include("config.php");
include("tags.php");
?>
<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Buscar imóveis - <?php echo $nomeL . ' - ' . $slogan; ?></title>

<link href="css/geral.css" rel="stylesheet" type="text/css" />
</head>
<body>

<!-- HEADER -->
<div id="header">
<?php include('topo.php'); ?>
</div>
<center>
<form name="busca" id="busca" method="post" action="busca.php">
<table width="936" border="0">
<tr>
<td width="129"><span class="Fleft busca_imovel_pag_detalhes">
<label>Negócio:</label>
</span></td>
<td width="123"><label class="busca_imovel_pag_detalhes">Tipo:</label></td>
<td width="123"><span class="Fleft">
<label class="Fleft busca_imovel_pag_detalhes">Cidade:</label>
</span></td>
<td width="121"><label class="Fleft busca_imovel_pag_detalhes">Bairro:</label></td>
<td width="131"><span class="Fleft">
<label class="Fleft busca_imovel_pag_detalhes">Valor mínimo:</label>
</span></td>
<td width="140"><label class="Fleft busca_imovel_pag_detalhes">Valor máximo:</label></td>
<td width="139">&nbsp;</td>
</tr>
<tr>
<td><span class="Fleft">
<select name="negocio_" class="campos_imovel_detalhes">
<option value="" >Todos</option>
<?php
$sql = mysql_query("SELECT id, tipo FROM negocio_tipo WHERE ativo='S'");
while( $linha = mysql_fetch_array( $sql ) ) {
echo '<option value="'.$linha['id'].'">'.$linha['tipo'].'</option>';
}
?>
</select>
</span></td>
<td><select name="tipo_" class="campos_imovel_detalhes">
<option value="">Todos</option>
<?php
$sql = mysql_query("SELECT id, tipo_nome FROM imoveis_tipo WHERE ativo='1'");
while( $linha = mysql_fetch_array( $sql ) ) {
echo '<option value="'.$linha['id].'">'.$linha['tipo_nome'].'</option>';
}
?>
</select></td>
<td><span class="Fleft">
<select name="cidade_" onChange="Dados(this.value);" class="campos_imovel_detalhes">
<option value="">Todas</option>
<?php
$sql = mysql_query("SELECT id, cidade FROM cidades WHERE ativo='1'");
while( $linha = mysql_fetch_array( $sql ) ) {
echo '<option value="'.$linha['id].'">'.$linha['cidade'].'</option>';
}
?>
</select>
</span></td>
<td><select name="bairro_" id="bairro_" class="campos_imovel_detalhes">
<option id="opcoes" value="">Todos</option>
<?php
$sql = mysql_query("SELECT id, cidade FROM bairros WHERE ativo= 1");
while( $linha = mysql_fetch_array( $sql ) ) {
echo '<option value="'.$linha['id].'">'.$linha['bairros'].'</option>';
}
?>//* alteração bairros
</select></td>
<td><span class="Fleft">
<input type="text" name="valorMin_" onKeyPress="mascara(this,Metros)" class="campos_imovel_detalhes"/>
</span></td>
<td><input type="text" name="valorMax_" onKeyPress="mascara(this,Metros)" class="campos_imovel_detalhes"/></td>
<td><input srname="submit" type="submit" class="btnEnviar botao_imovel_detalhes" value=" " ></td>
</tr>
</table>
</form>
</center>
<br class="clear" />
<!-- AND HEADER -->

<!-- CONTENT -->
<div id="content">

<h1>Busca de Imóveis</h1>

<?php

$cidade_ = strip_tags( $_POST['cidade_] );
$bairro_ = strip_tags( $_POST['bairros_'] );
$tipo_ = strip_tags( $_POST['tipo_] );
$negocio_ = strip_tags( $_POST['negocio_'] );
$valorMin_ = strip_tags( $_POST['valorMin_] );
$valorMax_ = strip_tags( $_POST['valorMax_'] );
$codigo_ = strip_tags( $_POST['codigo_] );

if( isset($_GET['cidade_'] ) ) $cidade_ = strip_tags( $_GET['cidade_'] );
if( isset($_GET['bairro_] ) ) $bairro_ = strip_tags( $_GET['bairro_'] );
if( isset($_GET['tipo_] ) ) $tipo_ = strip_tags( $_GET['tipo_'] );
if( isset($_GET['negocio_] ) ) $negocio_ = strip_tags( $_GET['negocio_'] );
if( isset($_GET['valorMin_] ) ) $valorMin_ = strip_tags( $_GET['valorMin_'] );
if( isset($_GET['valorMax_] ) ) $valorMax_ = strip_tags( $_GET['valorMax_'] );
if( isset($_GET['codigo_] ) ) $codigo_ = strip_tags( $_GET['codigo_'] );
/* MONTA CRITERIOS DE BUSCA */
$where = "i.ativo ='1'";

if ( !empty( $cidade_ ) ) {
$where .=" AND i.id_cidade='$cidade_'";
}
if ( !empty( $bairro_ ) ) {
$where .=" AND i.bairro='$bairro_'";
}

if ( !empty( $tipo_ ) ) {
$where .=" AND i.id_tipo_imovel='$tipo_'";
}

if ( !empty( $negocio_ ) ) {
$where .=" AND i.id_negocio_tipo='$negocio_'";
}

if ( !empty( $valorMin_ ) ) {
$where .=" AND i.valor>='$valorMin_'";
}

if ( !empty( $valorMax_ ) ) {
$where .=" AND i.valor='$valorMax_'";
}

if ( !empty( $codigo_ ) ) {
$where ="i.ativo='1' AND i.codigo='$codigo_'";
}

////////
$sql = mysql_query("SELECT i.*, t.tipo_nome, n.tipo, c.cidade FROM imoveis i
LEFT JOIN imoveis_tipo t ON (t.id = i.id_tipo_imovel)
LEFT JOIN negocio_tipo n ON (n.id = i.id_negocio_tipo)
LEFT JOIN cidades c ON (c.id = i.id_cidade)
WHERE $where") or print(mysql_error());

if (!isset( $_GET["pagina] ) )
$pagina = 1;
else
$pagina = strip_tags( $_GET["pagina"] );

$max=15;
$inicio = $pagina - 1;
$inicio = $max * $inicio;
$total = mysql_num_rows($sql);

/* calcula a quantidade de produtos sendo exibidos no momento */
$pgs = ceil($total / $max);
$de = $max * $pagina;
if($pagina == $pgs) $de = $total;
$temp = $inicio + 1;
echo "<p>Foram encontrados <b>$total</b> imóveis.</p>";
echo "<p align=\"center\"><b>Página:</b> $pagina de $pgs</p><br /><br />";
//////////

$sql = mysql_query("SELECT i.id, i.valor, i.foto_exibicao, i.quartos, i.garagem, i.codigo, t.tipo_nome, n.tipo AS negocio, c.cidade, c.uf, b.bairro FROM imoveis i
LEFT JOIN imoveis_tipo t ON (t.id = i.id_tipo_imovel)
LEFT JOIN negocio_tipo n ON (n.id = i.id_negocio_tipo)
LEFT JOIN cidades c ON (c.id = i.id_cidade)
LEFT JOIN bairros b ON (b.id = i.bairro)
WHERE $where ORDER BY valor ASC LIMIT $inicio, $max") or print(mysql_error());

while( $linha = mysql_fetch_array( $sql ) ) {

?>
<div class="listaImoveis">
<a title="<?php echo $linha['negocio] . ' ' . $linha['tipo_nome'] .' em '. $linha['cidade'] . ' /' . $linha['uf']; ?>" href=detalhes_imovel.php?Cod=<?php echo $linha['id];?>"><img src="img_imoveis/<?php echo $linha['foto_exibicao']; ?>" width=200" height="130" alt="<?php echo $linha['negocio] . ' ' . $linha['tipo_nome'] .' em '. $linha['cidade'] . ' /' . $linha['uf']; ?>" /></a>

<div class="listaImoveisbox">
<p><b><?php echo $linha['tipo_nome]; ?></b></p>
<p><?php echo $linha['negocio']; ?></p>
<p>C&oacute;digo: <?php echo $linha[codigo]; ?></p>
<p class="valor_busca">Valor: <?php echo ( empty( $linha['valor] ) || $linha['valor'] == '0.00' ? 'Consulte-nos' : 'R$ ' . number_format( $linha['valor'], 2, ',', '.') ); ?></p>
</div>

<div class="listaImoveisbox">
<p><b><?php echo $linha['cidade] . '/' . $linha['uf']; ?></b></p>
<p><?php echo $linha['bairro]; ?></p>
<p>Quartos: <?php echo $linha['quartos']; ?></p>
<p>Garagem: <?php echo $linha['garagem]; ?> vaga(s)</p>
</div>

<div class="listaImoveisbox">
<p class="fRight"><a title="<?php echo $linha['negocio'] . ' ' . $linha['tipo_nome'] .' em '. $linha['cidade'] . ' /' . $linha['uf']; ?>" href=detalhes_imovel.php?Cod=<?php echo $linha['id];?>"><img src="imagens/img-descricao-busca.jpg" border="0"></a></p>
</div>

</div>
<br class="clear" />
<?php } ?>
<br /><br /><br /><br />

<?php
echo "<p align=\"center\"><b>Página:</b> $pagina de $pgs</p><br /><br />";
?>

<div id="paginacao">
<?php
// Calculando pagina anterior
$menos = $pagina - 1;
// Calculando pagina posterior
$mais = $pagina + 1;
$pgs = ceil($total / $max);

$url = "cidade_=$cidade_&bairro_=$bairro_&tipo_=$tipo_&negocio_=$negocio_&valorMin_=$valorMin_&valorMax_=$valorMax_&codigo_=$codigo_";

if($pgs > 1 )
{
if($menos > 7)
echo "<a title='primeira pagina' class='lk' href='busca.php?$url'>Início</a> ";

if($menos >0)
echo "<a title='pagina anterior' class='lk' href='busca.php?$url&pagina=$menos'>Anterior</a> ";

if (($pagina-7) < 1 )
$anterior = 1;
else
$anterior = $pagina-7;

if (($pagina+7) > $pgs )
$posterior = $pgs;
else
$posterior = $pagina + 7;

for($i=$anterior;$i <= $posterior; $i++)
if($i != $pagina)
echo " <a title='pagina $i' href='busca.php?$url&pagina=$i'>$i</a>";
else
echo "<strong>$i</strong>";

if($mais <= $pgs)
echo " <a title='proxima pagina' class='lk' href='busca.php?$url&pagina=$mais'>Próxima</a>";

if($mais < ($pgs - 3))
echo " <a title='ultima pagina' class='lk' href='busca.php?$url&pagina=$pgs'>Última</a>";
}
?>
</div>

</div>
<br class="clear" />
<!-- AND CONTENT -->


<!-- FOOTER -->
<div id="footer">
<?php include('rodape.php'); ?>
</div>
<!-- FOOTER -->
</body>
</html>

Link para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts Recomendados

Até agora não há respostas para essa pergunta

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      652k
×
×
  • Criar Novo...