Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7887287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:32:24+00:00 2026-06-03T05:32:24+00:00

————————————————————————————— | products_id | net_price | special_price | special_expire | special_status | ————————————————————————————- |

  • 0
---------------------------------------------------------------------------------------
|   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
---------------------------------------------------------------------------------------

Where products_id, net_price, special_price, special_expire is self explanatory and special_status defines 1 as to apply the special price and 0 as to disable the special price.

I have a search form wherein there is a price range.

<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>

I’m having a hard time developing or finding a solution to conditionally select net_price if either special_price is 0.000, the special_expire date value has passed or the special_status‘s value is 0. Then if there is a value in the special_price, special_expire date value hasn’t passed and the special_status‘s value is 1 then select the special_price value.

This is the picture that i want to come from. ( I know that this is not possible but, i guess this is the best way to picture out my problem. )

    $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
    }";

I hope you can help me guys..
Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:32:26+00:00Added an answer on June 3, 2026 at 5:32 am

    Try this:

    $sql = "SELECT products_id, products_price, special_price, special_expire, 
    special_status, products_name, 
    case when (special_price > 0 and special_expire > Now() and special_status != 0) 
    then special_price else net_price end price from " . TABLE_GLOBAL_PRODUCTS . " 
    where products_name like '%" . $search_key . "%' 
    having price >= ".$pricefrom_key." and price <= ".$priceto_key.";
    

    Make sure you escape your inputs!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

&mdash; or &#8212; Is there a difference between these? Is one better-supported than the
I'm using a DatePicker ( org.apache.wicket.extensions.yui.calendar.DatePicker — Javadoc ) in a form. The form
string formIdList = 8256, 8258, 8362, 8120, 8270, 8271, 8272, 8273, 8257, 8279, 8212,
The correct encoding for em-dash is supposedly &#8212; , however when the semi-colon is
I'm using some of Firefox's specially-defined values for cursor, in particular -moz-zoom-in -moz-zoom-out -moz-grab
I'm currently working on a little harvester, using this dataset of 2700 foundations .
Basically, is there a way to write a.children('.outer').children('.inner') without the intermediate selector? I can't
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
So to start, I have an array of XML files. These files need to
I recently ran against a very interesting site that expresses a very interesting idea

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.