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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:52:39+00:00 2026-05-20T07:52:39+00:00

I need to build an app (PHP/MySQL but I don’t think it matters), letting

  • 0

I need to build an app (PHP/MySQL but I don’t think it matters), letting a user to input a set of rules matching particular products. That should look like a form, allowing to select a key and to input its value, but supporting grouping with OR and AND statements. For example the user should be able to input the following product rules: (price over 100 and red color) or (price over 50 and green color), weight over 2 and so on. The problem is, I’m not sure how should I store that in the database and not sure how to code UI for that. Is there any common approach to solving such a problem?

Thanks

  • 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-05-20T07:52:39+00:00Added an answer on May 20, 2026 at 7:52 am

    I’ve been thinking about that for a while. Here’s what I came to:

    There is a rule table:

    rule_id int,
    field1 varchar,
    rule1_id int,
    operand varchar, --whatever, can be int, if operand is described in other table.
    field2 varchar,
    rule2_id int
    

    Your example rule can be expressed in this way:

    rule_id  field1   rule1_id      operand     field2      rule2_id
    1       'price'     null            '>'       '100'       null
    2       'color'     null            '='       'red'       null
    3       null        1               'and'     null        2
    4       'price'     null            '>'       '50'        null
    5      'color'    null            '='       'green'     null
    6       null        4               'and'     null        5
    7       null        3               'or'      null        6
    

    You will then be referencing the complex rule with rule_id=7. To resolve that rule, each other rule should be resolved recursively. field can be a field in a database, as well as the operand. You would then be able to form SQL queries from this saved data. It’s also easy to load and present into controls, so the user can edit this rule using combo boxes (HTML <select>) and stuff.

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

Sidebar

Related Questions

I need to build app with user messages (dialogs). I've solved this problem by
I want to build a social network app for Android. But, I don't know
I need to build a php app, and I was thinking about using a
I need to build a backend for an iPad app done in Objective C.
I'm trying to build a mobile app in HTML5. I need to store the
Why you may ask? Because i have built the app on mysql and need
I'm building a new game and I need to build a web app to
I need to build an application outside of my normal comfort zone (web/PHP/JavaScript). Should
I am (trying) to build a web app, first one :) I need to
I'm going to build an app using a lot of interfaces for the user

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.