mardi 17 mai 2016

fetch data from database as checkbox and show checked values in php

Hi I use single GET variable to fetch data from database on a webpage. I want to refine that data further using checkbox or radio buttons. How is it possible ??

URL is http://localhost/ldh/list.php?bcat=cars. List page gets the value of bcat from URL and displays information about cars like model name, company name, capacity etc.

list.php

$str=$_GET['bcat'];
$resultss=mysqli_query($mysqli,"SELECT * FROM car WHERE bcat='$str'");
                $rows1=mysqli_num_rows($resultss);
                $i=1;
                if($rows1)
                    {
                        while($rows1=mysqli_fetch_array($resultss))
                        {
                            $vid=$rows1['id'];
                            <?php echo $rows1['logo']; ?>
                            <?php echo $rows1['name']; ?>
                            <?php echo $rows1['company']; ?>
                            <?php echo $rows1['price']; ?>
                        }
                    }

List.php also has a form to filter data.

            <form id="form" method="post" action="vlist.php?bcat=<?php echo $str;?>" >
                <li><input type="checkbox" name="company[]" value="Maruti"/>Maruti</li>
                <li><input type="checkbox" name="company[]" value="Honda" />Honda</li>            
                <li><input type="checkbox" name="company[]" value="Hyundai"/>Hyundai</li>
                <p class="filter-list"><input type="submit" value="Go.." /></p>
            </form>

Now i want to show only those cars on the same page whose campany(s) i select using checkbox. Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire