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 8101033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:53:11+00:00 2026-06-05T22:53:11+00:00

I have a search form where user can search for products within their specified

  • 0

I have a search form where user can search for products within their specified price range.
Wherein I have 2 input boxes 1 is for the starting range and the other is for the ending range.

I have 3 products stores in my database table. With prices 2300.0000, 1200.0000, 1000.5000 respectively.

Im having a problem with selecting values within the inputted price range. The problem is that, when I input values like

  1. 100 starting range to 1100 ending range. The products with 1200.0000
    and 1000.5000 is being displayed instead of only the 1000.5000
    product.
  2. 0 starting range to 1100 ending range or 1000.50 ending range. The
    products with 1200.0000 and 1000.5000 is being displayed instead of
    only the 1000.5000 product.
  3. 1100 starting range. Only the product with 2300.0000 is being
    displayed instead of both 2300.0000 and 1200.0000. But when the
    starting values is less than or equal 500 all the 3 products is
    being displayed.

This is the code i am using.

function db_prepare_input($string)
{
    if (is_string($string)) {
        return trim(stripslashes($string));
    } elseif (is_array($string)) {
        reset($string);
        while (list($key, $value) = each($string)) {
            $string[$key] = db_prepare_input($value);
        }
        return mysql_real_escape_string($string);
    } else {
        return mysql_real_escape_string($string);
    }
}

$pricefrom_key = db_prepare_input(number_format($_GET['pricefrom'], 4, '.', ''));
$priceto_key = db_prepare_input(number_format($_GET['priceto'], 4, '.', ''));

// Price Range
if (!empty($_GET['pricefrom']) && !empty($_GET['priceto'])) {
    $price_range = " having price >= ".$pricefrom_key." and price <= ".$priceto_key;
}
elseif(empty($_GET['pricefrom']) && !empty($_GET['priceto']))
{
    $price_range = " having price >= 0 and price <= ".$priceto_key;
}

elseif(!empty($_GET['pricefrom']) && empty($_GET['priceto']))
{
    $price_range = " having price >= ".$pricefrom_key;
}

elseif(!empty($_GET['pricefrom']) && !empty($_GET['priceto']))
{
    $price_range = "";
}

$catglobal_sql = "select p.blog_id, p.global_category_id, p.products_id, p.products_currency, p.products_type, p.products_name, p.products_description, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_weight, p.products_status, p.products_tax_class_id, p.manufacturers_id, p.products_ordered, p.specials_new_products_price, p.specials_date_added, p.specials_last_modified, p.expires_date, p.date_status_change, p.status, p.display_product, case when (p.specials_new_products_price > 0 or p.specials_new_products_price != 0000-00-00 and p.expires_date > Now() and p.status != 0) then p.specials_new_products_price else p.products_price end price from ".TABLE_GLOBAL_PRODUCTS." p INNER JOIN ".TABLE_STORES." s ON s.blog_id = p.blog_id where MATCH (p.products_name,p.products_description) AGAINST ('%".$search_key."%') OR p.products_name like '%".$search_key."%' and s.countries_id = '168' ".$search_cat." and p.display_product = '1' and p.products_status = '1' ".$price_range." order by p.products_date_added DESC, p.products_name";

I tried, adding die($catglobal_sql); and the result is,

select p.blog_id, p.global_category_id, p.products_id, p.products_currency, p.products_type, p.products_name, p.products_description, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_weight, p.products_status, p.products_tax_class_id, p.manufacturers_id, p.products_ordered, p.specials_new_products_price, p.specials_date_added, p.specials_last_modified, p.expires_date, p.date_status_change, p.status, p.display_product, case when (p.specials_new_products_price > 0 or p.specials_new_products_price != 0000-00-00 and p.expires_date > Now() and p.status != 0) then p.specials_new_products_price else p.products_price end price from wp_global_products_table p INNER JOIN wp_blogs s ON s.blog_id = p.blog_id where MATCH (p.products_name,p.products_description) AGAINST ('%cotton%') OR p.products_name like '%cotton%' and s.countries_id = '168' and p.products_currency = 'php' and p.display_product = '1' and p.products_status = '1' and p.products_type = 'a' having price >= 0 and price <= 1200.0000 order by p.products_date_added DESC, p.products_name

What seems to be the problem??

  • 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-05T22:53:12+00:00Added an answer on June 5, 2026 at 10:53 pm

    I have found the problem.. Its on the case.. i have modified it to case when p.specials_new_products_price >= 0.0000 and p.expires_date > Now() and p.status != 0 then p.specials_new_products_price else p.products_price end price

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

Sidebar

Related Questions

On my homepage I have a simple search form. The user can enter some
I have a search form that the user can search for an Article content
i have a search form where a user can search for certain fields in
I have created a form where the user can search the database, and the
I have a form where user can select search criteria. The criterias are say:
I have a search form, where user can look up estates he owns (search
I have a search form with default values. As the user loades the page,
I have a CCK field price which the user can fill in. I would
I have a search form with filters. 1 filter is range which is to
I have a search form and result list. The form allows the user to

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.