1
Hi, I made a page that searches the registered products and then appears the results on the results page.php results.
I would like that on this page results.php later could make a more accurate query as for lower price appear first, have the option to choose the new or used product, appear physical or legal person.
I posted my code on Pastebin: http://pastebin.com/PVkBvA9R
<?php include 'header.php'; ?>
<header class="docs-top">
<div class="container docs-header">
Todos os resultados
</div>
</header>
<section>
<div class="container">
<?php
require 'conexao.php';
$produto = $_POST['produto'];
$sql = mysql_query("SELECT * FROM usuario where produto LIKE '%".$produto."%' ");
// SELECT preco FROM usuario ORDER BY preco ASC
$row = mysql_num_rows($sql);
if ($row > 0) {
while ($linha = mysql_fetch_array($sql)) {
$produto = $linha['produto'];
$bairro = $linha['bairro'];
$preco = $linha['preco'];
$telefone = $linha['telefone'];
$nome = $linha['nome'];
$estado = $linha['estado'];
}
} else {
echo "Nenhum resultado encontrado";
}
?>
<div class="well recomentadion clearfix">
<h1>Pesquisar</h1>
<form action="" method="POST">
<fieldset>
<div class="form-group col-md-3">
<label class="" for="advertisement">Título do Anúncio </label>
<div class="control mr-30">
<input type="text" id="title" name="title" class="form-control" value="" placeholder="Título" data-original-title="" title="">
</div>
</div>
<div class="form-group col-md-3">
<label class="" for="advertisement">Novo/Usado</label>
<div class="control mr-30">
<select class="form-control">
<option>Novo</option>
<option>Usado</option>
</select>
</div>
</div>
<div class="form-group col-md-3">
<label class="" for="advertisement">Empresa/P. fisica</label>
<div class="control mr-30">
<select class="form-control">
<option>Todos</option>
<option>Empresa</option>
<option>Pessoa fisica</option>
</select>
</div>
</div>
<div class="form-group col-md-3">
<label class="" for="advertisement">Ordernar por Preço</label>
<div class="control mr-30">
<select class="form-control">
<option>Menor preço</option>
<option>Maior preço</option>
</select>
</div>
</div>
<div class="clear"></div>
<input type="submit" style="margin-top:20px;" name="submit" class="btn btn-primary pull-right" value="Pesquisar">
</fieldset>
</form>
</div>
<!-- produto -->
<div class="bs-docs-example">
<table class="table table-bordered">
<tbody>
<tr>
<td align="center">:<img src="http://wcloudstatic.s3.amazonaws.com/img/no_image.jpeg" width="150" height="150" /></td>
<td><?php echo ".$produto"; ?> <br><br> <?php echo ".$bairro"; ?> - <?php echo ".$estado"; ?><br> <?php echo ".$nome"; ?> - <?php echo ".$telefone"; ?></td>
<td><?php echo ".$preco"; ?></td>
</tr>
</tbody>
</table>
</div>
<!-- /produto -->
</div>
</section>
<?php include 'footer.php'; ?>
Always post the code or excerpt of the code you are doubtful here, to facilitate the analysis of colleagues site.
– user28595
Okay, you said your goal, but you didn’t say what’s stopping you or what the problem/difficulty is. From what I’ve seen, your code should be displaying only the last record and not the whole list.
– DontVoteMeDown