Mini Shell
<?php
include('topo.inc.php');
include('menu.inc.php');
?>
<script>
function valida()
{
document.form.cmd.value = "filtrar";
}
</script>
<section id="content">
<div class="g12">
<h1>Imóveis cadastrados no site</h1>
<p></p>
<?=$msg?>
<!-- area do form -->
<form name="form" id="form" method="post" autocomplete="off">
<input type="hidden" name="cmd">
<fieldset>
<section>
<label for="text_field">Palavra chave:</label>
<div><input type="text" id="chave" name="chave" value="<?=$_POST['chave']?>"></div>
</section>
<section>
<label for="dropdown">Tipo:</label>
<div>
<select name="idcategoria" id="idcategoria" >
<option value="">Selecione um tipo</option>
<option value="1" <?=(1 == $_POST['tipo']) ? 'selected' : '' ?>>Aluguel</option>
<option value="2" <?=(2 == $_POST['tipo']) ? 'selected' : '' ?>>Venda</option>
</select>
</div>
</section>
<section>
<div><button class="i_tick icon" onClick="javascript: valida();" >Buscar</button></div>
</section>
</fieldset>
</form>
<?php
if($_POST['cmd'] == 'filtrar')
{
$strWhere = "";
$chave = anti_injection($_POST['chave']);
$tipo = anti_injection($_POST['tipo']);
if($chave)
$strWhere .= " AND (titulo LIKE '%$chave%' OR nome_imovel LIKE '%$chave%' OR email LIKE '%$chave%' OR endereco LIKE '%$chave%' OR bairro LIKE '%$chave%' OR cidade LIKE '%$chave%' OR uf LIKE '%$chave%' OR bairro LIKE '%$chave%' OR observacao LIKE '%$chave%')";
if($tipo)
$strWhere .= " AND tipo = '$tipo'";
$str = "SELECT DISTINCT * FROM imoveis_site WHERE 1 = 1 $strWhere ORDER BY codigo DESC";
$rs = mysql_query($str) or die(mysql_error());
$num = mysql_num_rows($rs);
if($num > 0)
{
?>
<h1>Retorno da busca</h1>
<p><?=$num?> registros encontrados</p>
<fieldset>
<table >
<thead>
<tr>
<th>ID</th>
<th>Nome</th>
<th>Telefone / email</th>
<th>Imóvel</th>
<th>Endereço do imóvel</th>
<td>Descrição / observações</td>
</tr>
</thead>
<tbody>
<?php
while($vet = mysql_fetch_array($rs))
{
?>
<tr>
<td>#<?=$vet['codigo']?></td>
<td><?=$vet['nome']?></td>
<td>
Telefone: <?=$vet['codigo']?><br />
Email: <?=$vet['email']?>
</td>
<td>
<?=$vet['nome_imovel']?>
<?php
if($vet['t_aluguel'] != 1) {
echo '<br />Aluguel: Não';
} else {
echo '<br />Aluguel: Sim';
}
if($vet['t_venda'] != 1) {
echo '<br />Venda: Não';
} else {
echo '<br />Venda: Sim';
}
?>
</td>
<td>
Endereço: <?=$vet['endereco']?><br />
Bairro: <?=$vet['bairro']?><br />
Cidade: <?=$vet['cidade']?><br />
UF: <?=$vet['uf']?>
</td>
<td><?=nl2br($vet['observacao'])?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</fieldset>
<?php
}
}
?>
</div>
</section>
<?php include('rodape.inc.php'); ?>
Zerion Mini Shell 1.0