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

  • SEARCH
  • Home
  • 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 7926581
In Process

The Archive Base Latest Questions

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

I have these mysql table, ——————————————————————- | products_id | date_added | date_modified | |

  • 0

I have these mysql table,

 -------------------------------------------------------------------
 |   products_id   |   date_added              |  date_modified    |
 | -----------------------------------------------------------------
 |    1            |   2012-03-31 15:36:01     |  2012-5-03 00:00  | 
 | -----------------------------------------------------------------
 |    2            |   2012-03-31 15:38:01     |  2012-5-04 00:00  | 
 | -----------------------------------------------------------------
 |    3            |   2012-03-31 15:40:01     |  NULL             | 
 -------------------------------------------------------------------

I wanted to display value depending on the selected time on which values is not null.

If date_modified has a date value then use date_modified as its date. If it is NULL then use date_added as its date.

if($_get['duration'] =="0") {
  $duration = <select all regardless of date>;
} 
elseif ($_get['duration'] =="24") {
  $duration = <select all that less than 24 hours>;
} 
elseif ($_get['duration'] =="15") {
  $duration = <select all that less than 15 days>;
}

This is my mysql query,

$catglobal_sql = "select blog_id, global_category_id, products_id, products_currency, products_type, products_name, products_description, products_quantity, products_model, products_image, products_price, products_date_added, products_last_modified, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id, products_ordered, specials_new_products_price, specials_date_added, specials_last_modified, expires_date, date_status_change, status, display_product, case when (specials_new_products_price > 0 and expires_date > Now() and status != 0) then specials_new_products_price else products_price end price from " . TABLE_GLOBAL_PRODUCTS . " where products_name like '%" . $search_key . "%' and products_currency = '" . $currency_key . "' and display_product = '1' and products_status = '1' having price >= ".$pricefrom_key." and price <= ".$priceto_key." order by products_date_added DESC, products_name";

Can’t think of a solution for this. Please help.

  • 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-03T18:50:26+00:00Added an answer on June 3, 2026 at 6:50 pm

    Assuming you want to use the expires_date date and it is of type date or datetime

    $duration = "";
    if ($_get['duration'] == "24") {
      $duration = " AND DATE_SUB(expires_date, INTERVAL 24 HOUR) > NOW() ";
    } 
    elseif ($_get['duration'] == "15") {
      $duration = " AND DATE_SUB(expires_date, INTERVAL 15 DAY) > NOW() ";
    }
    
    $catglobal_sql = "select 
        <your_fields>
        FROM " . TABLE_GLOBAL_PRODUCTS . " 
        WHERE 
            products_name like '%" . $search_key . "%' and 
            products_currency = '" . $currency_key . "' and 
            display_product = '1' and 
            products_status = '1' 
            $duration
            HAVING price >= ".$pricefrom_key." and price <= ".$priceto_key." 
        ORDER BY products_date_added DESC, products_name";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some jpg images in MySQL table. How can I display these images?
I have a MySQL table where there is a 'date_added' (date) field, 'time_added' (time)
I have these mysql dates in a table of my database, 2010-07-16 20:09:06 2010-08-16
I have these two tables in mysql: create table a ( id INT NOT
In my table (MySQL) I have these fields: id - primary, auto_increment hash -
I have a MySQL table of pages with these fields ( id , parentID
Think I have a mysql table TBL of these keys TBL A_KEY X_KEY B_KEY
I have multiple entries in a mysql table field, these are separated with commas;
I have these 2 mysql queryes SELECT `name` AS name1,`id` AS id1 FROM `table`
In MySQL I have these 3 tables : CREATE TABLE IF NOT EXISTS Seasons

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.