I am trying to create a search system in db however it is returning only one result, the last address in the table (I had managed to get them all returned, however after changing the layout I went to test and did not give more, even deleting 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'm using bootstrap and would like them to return as follows:
<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>