Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $busca = $_POST['busca'];
- if($busca == "" or $busca == " "){
- echo'<center><strong>Digite algo para buscar</strong></center>';
- }else{
- $busca_dividida = explode(" ",$busca);
- $quant = count($busca_dividida);
- $id_mostrado = array("");
- for($i=0;$i<$quant;$i++){
- $pesquisa = $busca_dividida[$i];
- echo"<main class='sugestoes'>";
- #################################################o problema esta logo abaixo #########################
- $sql = mysqli_query($conexao, "SELECT * FROM teste WHERE tag LIKE '%$pesquisa%' OR nome LIKE '%$pesquisa%'");
- $quant_campos = mysqli_num_rows($sql);
- if($quant_campos == 0){
- echo '<center><strong>Nenhum Resultado Obitido!</strong></center>';
- echo"<main class='sugestoes'>";
- }else{
- while($linha = mysqli_fetch_array($sql)){
- $id = $linha['id'];
- $tag = $linha['tag'];
- $nome = $linha['nome'];
- $preco = $linha['preco'];
- $link_remedio = $linha['imagem'];
- if(!array_search($id, $id_mostrado )){
- echo"
- <article class='sugest'>
- <a href='#'><img src=".$link_remedio." alt='Imagem do Remédio'></a>
- <div class='inner'>
- <p>".$nome."</p>
- <p>".$preco."</p>
- <button>Adicionar a cesta</button>
- </div>
- </article>
- ";
- array_push($id_mostrado, "$id");
- }
- }echo"</main>";
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement