---------------------------------------------------------------------------------------
| products_id | net_price | special_price | special_expire | special_status
| -------------------------------------------------------------------------------------
| 1 | 500 | 200 | 2012-5-03 00:00 | 1
| -------------------------------------------------------------------------------------
| 2 | 600 | 300 | 2012-6-04 00:00 | 0
| -------------------------------------------------------------------------------------
| 3 | 700 | 400 | 2012-7-05 00:00 | 1
---------------------------------------------------------------------------------------
其中products_id
, net_price
, special_price
,special_expire
是不言自明的,special_status
定义1
为应用特价和0
禁用特价。
我有一个搜索表单,其中有一个价格范围。
<form method="get" action="http://website.com">
<input type="text" id="ref-search" name="search" value="<?php echo $search_value;?>" class="text" size="55" placeholder="Type a keyword." style="height: 30px;
width: 89%;">
<label>Price Range:</label><br>
<span class="price-range">
From <input type="text" id="price1" name="pricefrom"
value="<?php echo $pricefrom_value; ?>" class="text" style="
height: 20px;
width: 22%;">
to <input type="text" id="price2" name="priceto"
value="<?php echo $priceto_value; ?>" class="text" style="
height: 20px;
width: 22%;">
</form>
我很难开发或找到一个解决方案来有条件地选择net_price
是否special_price
是0.000
、special_expire
日期值已通过或special_status
的值是0
。然后,如果 中有一个值,则special_price
日期special_expire
值尚未通过,然后选择该special_status
值。1
special_price
这是我想要的图片。(我知道这是不可能的,但我想这是解决我的问题的最好方法。)
$sql = "select products_id, products_price, special_price, special_expire,
special_status, products_name from " . TABLE_GLOBAL_PRODUCTS . " where
products_name like '%" . $search_key . "%'
and /**Where the condition starts**/
if(special_value is =="0.000" || special_expire == <EXPIRED> ||
special_status =="0") {
products_price >= ".$pricefrom_key." and products_price <= ".$priceto_key."
} else {
specials_new_products_price >= ".$pricefrom_key."
and specials_new_products_price <= ".$priceto_key." order by products_name
}";
我希望你们能帮助我。谢谢。