Advertisement
Guest User

Problema

a guest
Oct 21st, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.40 KB | None | 0 0
  1. <?php
  2.     $busca = $_POST['busca'];
  3.            
  4.         if($busca == "" or $busca == " "){
  5.                 echo'<center><strong>Digite algo para buscar</strong></center>';
  6.             }else{
  7.             $busca_dividida = explode(" ",$busca);
  8.             $quant = count($busca_dividida);
  9.             $id_mostrado = array("");
  10.            
  11.         for($i=0;$i<$quant;$i++){
  12.             $pesquisa = $busca_dividida[$i];
  13.             echo"<main class='sugestoes'>";
  14.                 #################################################o problema esta logo abaixo   #########################
  15.             $sql = mysqli_query($conexao, "SELECT * FROM teste WHERE tag LIKE '%$pesquisa%' OR nome LIKE '%$pesquisa%'");
  16.             $quant_campos = mysqli_num_rows($sql);
  17.             if($quant_campos == 0){
  18.                     echo '<center><strong>Nenhum Resultado Obitido!</strong></center>';
  19.                     echo"<main class='sugestoes'>";
  20.             }else{
  21.                
  22.             while($linha = mysqli_fetch_array($sql)){
  23.                     $id = $linha['id'];
  24.                     $tag = $linha['tag'];
  25.                     $nome = $linha['nome'];
  26.                     $preco = $linha['preco'];
  27.                     $link_remedio = $linha['imagem'];
  28.                    
  29.                    
  30.                     if(!array_search($id, $id_mostrado )){
  31.                     echo"
  32.                         <article class='sugest'>
  33.                             <a href='#'><img src=".$link_remedio." alt='Imagem do Remédio'></a>
  34.                             <div class='inner'>
  35.                                 <p>".$nome."</p>
  36.                                 <p>".$preco."</p>
  37.                                 <button>Adicionar a cesta</button>
  38.                             </div>
  39.                         </article>
  40.                     ";
  41.                     array_push($id_mostrado, "$id");
  42.                     }  
  43.                 }echo"</main>";
  44.             }
  45.         }
  46.     }
  47.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement