在php中从低到高和从高到低过滤数据

时间:2019-07-16 10:51:55

标签: php

我有一个下拉列表,其中包括从低到高以及从高到低的价格过滤器以及ALL。从数据库中获取与价格相关的数据并在页面加载后显示数据。但是该下拉列表将是静态下拉列表

默认情况下,它将在插入数据库时​​显示所有数据库。但是当我们在下拉列表中选择从低到高时,则数据应该从低到高排列。 如果我在下拉列表中选择了任何值但无法正常工作,则使用此查询来显示数据。

SELECT * FROM list ORDER BY *[SOME_COLUMN] [ASC|DESC]

<form method="post" action="#">
                                    <div class="col-md-6">
                                        <div class="option-box">
                                            <div class="sel-label">Filter Property</div>
                                            <div class="form-group">
                                                <select class="custom-select-box form-control">
                                                    <option value="0">All</option>
                                                    <option value="1">1 BHK</option>
                                                    <option value="2">2 BHK</option>
                                                    <option value="3">3 BHK</option>
                                                    <option value="4">Villas - Duplex</option>
                                                    <option value="5">Indipendent Houses</option>
                                                    <option value="6">Open Plots</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="option-box">
                                            <div class="sel-label">Filter Price</div>
                                            <div class="form-group">
                                                <select class="custom-select-box form-control">
                                                    <option>All</option>
                                                    <option value="DESC">High to Low</option>
                                                    <option value="ASC">Low to High</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                            </form>
<div class="filter-list row clearfix">
                <!--Property Box Two-->
                <div class="property-box-two mix all for-rent col-lg-4 col-md-4 col-sm-6 col-xs-12">
                    <div class="inner-box">
                        <div class="image-box">
                            <figure class="image"><a href="#"><img src="images/featured-image-11.jpg" alt=""></a></figure>
                            <div class="property-price"><i class="fa fa-inr"></i> 30,000,000</div>
                        </div>
                        <div class="lower-content">
                            <div class="property-title">
                                <h3><a href="#">Auto Nagar</a></h3>
                                <div class="location"><span class="fa fa-map-marker"></span> Hyderabad.</div>
                            </div>
                            <div class="prop-info">
                                <ul class="clearfix">
                                    <li><strong>3</strong> BHK</li>
                                    <li><strong>2</strong> Baths</li>
                                    <li><strong>3542</strong> sq ft.</li>
                                </ul>
                            </div>
                        </div>
                        <div class="bottom-content">
                            <div class="link"><a href="property-details.html">Get Full Details <span class="fa fa-angle-right"></span></a></div>
                        </div>
                    </div>
                </div>                                
            </div>

我想要的数据库表

S.no  City Place Price
1     abc  abc   1000 
2     def  def    800
3     rgw  ere    2000

0 个答案:

没有答案