2
I’m trying to create a search system in db however this returning only one result, the last address in the table (I had managed to make them all return, however after changing the layout I went to test and gave no more, even erasing everything and returning from when it worked).
<?php
$host="localhost";
$user="root";
$password="";
$db="db";
$con = new mysqli($host,$user,$password,$db);
$verifica = 0;
$city = $_POST['city'];
$bairrop = $_POST['bairrop'];
if(!empty($_POST['city']) && !empty($_POST['bairrop'])){
$result_search = "SELECT * FROM user WHERE cidade LIKE '%$city%' AND bairro LIKE '%$bairrop%'";
$resultado_search = mysqli_query($con, $result_search);
$verifica = mysqli_num_rows($resultado_search);
}elseif (!empty($_POST['city'])) {
$result_search = "SELECT * FROM user WHERE cidade LIKE '%$city%'";
$resultado_search = mysqli_query($con, $result_search);
$verifica = mysqli_num_rows($resultado_search);
}elseif (!empty($_POST['bairrop'])) {
$result_search = "SELECT * FROM user WHERE bairro LIKE '%$bairrop%'";
$resultado_search = mysqli_query($con, $result_search);
$verifica = mysqli_num_rows($resultado_search);
}
if($verifica > 0){
while($row_search = mysqli_fetch_array($resultado_search)) {
$nome = $row_search['nome_usuario'];
}
}else{
echo "Nenhum resultado encontrado.";
}
?>
2: I am using the bootstrap and would like them to return in the following way:
<div class="media">
<div class="media-left">
<a href="#">
<img class="media-object" src="AVATAR" alt="...">
</a>
</div>
<div class="media-body">
<h4 class="media-heading">AQUI O NOME</h4>
DESCRIÇÃO
</div>
</div>