How to use Range Slider for images

Asked

Viewed 30 times

1

I have a car sales site to do, but I’m having a hard time with the filters where I need the maximum price and the minimum price, so I did a range slider for the first time but I can’t get it to reduce car options by lowering the price.

inserir a descrição da imagem aqui

Always stay all the cars as I do to stay only the cars with the price within the limits?

<?php
        include 'conn.php';
        mysqli_set_charset($con,"utf-8");

        $result = mysqli_query($con,"SELECT preco from carros_desc where preco = (SELECT preco FROM carros_desc ORDER BY preco ASC LIMIT 1)");

        while($row = mysqli_fetch_array($result)){

        $preco = $row['preco'];

        echo "<input type='range' name='price-min' id='price-min' value='$preco' min='0' max='100000'>";

        }

        $result2 = mysqli_query($con,"SELECT preco from carros_desc where preco = (SELECT preco FROM carros_desc ORDER BY preco DESC LIMIT 1)");

        while($row2 = mysqli_fetch_array($result2)){

        $preco2 = $row2['preco'];

        echo "<input type='range' name='price-min' id='price-min' value='$preco2' min='0' max='100000'>
        </div>
        </div><div id='cars'>";

        }

        $result3 = mysqli_query($con,"SELECT carros.modelo, carros_img.img, carros_desc.preco, carros_desc.comb FROM carros, carros_desc, carros_img WHERE carros.id = carros_desc.id_fk and carros.id = carros_img.id_fk and carros_desc.preco BETWEEN '$preco' and '$preco2' order by carros_desc.preco ASC");

                        while($row3 = mysqli_fetch_array($result3)){

                        $img = $row3['img'];
                        $modelo = $row3['modelo'];
                        $comb = $row3['comb'];
                        $preco3 = $row3['preco'];

                        echo "<div class='img'>
                                <a target='_blank' href='imagens/viaturas/$img'>
                                    <img src='imagens/viaturas/$img' alt='$img' width='300' height='200'>
                                </a>
                                <div class='desc'>
                                    <p>$modelo</p>
                                    <p>$comb</p>
                                    <p>$preco3</p>
                                </div>
                            </div>";
                        }
                        mysqli_close($con);
                    ?>
  • Is there no error? The above code represents all the resource you want to use?

  • That’s just what I did I don’t know if it’s right but that’s what it seemed to me, by logic.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.