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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:32:44+00:00 2026-05-13T11:32:44+00:00

I need to create a GUI, using which users can select several attributes which

  • 0

I need to create a GUI, using which users can select several attributes which will be used to query the database to find suitable persons. I’m looking for ideas how to dynamically generate the database query according to user’s choices.

Query will contain several fields, but to get the idea I will include only three of those below as an example:

  • Occupation – there can be 0 to n occupation strings. If occupation strings are given, one of them have to match.

  • Age – age can be given as:

    1. exact match (30)
    2. range (e.g. 30-40)
    3. less than a value (-40)
    4. more than a value (30-)

Age parameter is optional in the query. In addition, user can specify whether age is a required parameter. If it’s not required, and a person does not have age is his/her profile, age criteria is ignored for this person.

  • Height – similar as age

Example queries:

No criteria has been given:

select * from persons

Only occupation has been given:

select * from persons where occupation = 'dentist'

Several occupations have been given:

select * from persons where (occupation = 'dentist' or occupation = 'engineer')

Age has been given as a greater than value, and it’s required to exist on person’s profile:

select * from persons where age >= 30

Height has been given as a range, and it’s not required to exist on person’s profile:

select * from persons where (height is null or (height >= 30 and height <= 40))

Combination of different criteria:

select * from persons where occupation = 'dentist' and age >= 30 and (height is null or (height >= 30 and height <= 40))

I have already implemented code which is capable of generating queries as strings, but it certainly is not too pretty. I’m looking for ideas what would be the most efficient and prettiest way to achieve this.

  • 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-13T11:32:45+00:00Added an answer on May 13, 2026 at 11:32 am

    Try something like Zend_Db_Select. It provides a (fluent) interface for generating queries and handles the syntax creation for you, e.g.

    $select = $db->select();
    $select->from( /* ...specify table and columns... */ )
           ->where( /* ...specify search criteria... */ )
           ->where( /* ...specify other criteria... */ )
           ->order( /* ...specify sorting criteria... */ );
    

    I had a similar requirement in one my recent projects where users have a configuration file containing filter criteria that are automatically applied to certain tables in the database, thus limiting what the users are allowed to see, e.g, limit Products by fixed Customer but still allow dynamic filtering through GUI, e.g. for a Product category.

    I solved it by having my model return a base query and then running this base query through a decorator that would apply all criteria the user has in his config, so for instance (faux code).

        request = Request->getParams()            // selection criteria set from GUI
        sql     = Products->getBaseQuery(request) // basic query for requested View
        sql     = Decorator->applyUserConfig(sql) // custom fixed user filter
        results = sql->execute()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 291k
  • Answers 291k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Probably, you want this: for (int i = 0; i… May 13, 2026 at 5:57 pm
  • Editorial Team
    Editorial Team added an answer If you have a static file public/index.html then this should… May 13, 2026 at 5:57 pm
  • Editorial Team
    Editorial Team added an answer See this post, I believe your hinting at using fieldsets… May 13, 2026 at 5:57 pm

Related Questions

We're building an application designed to run on Windows-based servers. One of the considerations
I wrote a quick program in python to add a gtk GUI to a
My small utility application asks the user for an output directory via a GUI
I'm trying to write an embedded ( NOT web, not enterprise ) content management
Since I've been learning Java, I've been able to create GUI programs. However, even

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.