Need Help With Dynamically Writing a Query

I am hoping to get some help from the SitePoint community on a PHP challenge I am trying to get going.

I need to build a search functionality, so users can select many parameters, and then run a query across many tables to get their results.

Our website allows users to see new homes being built around the city, filtered by the area of the city, and the type (single or multi family) they are most interested in.

Here are my tables:

Quadrant
ID
Name
Abbreviation

Home Builder
ID
Name
Website
Type (single or multi)

Builder Relationships
ID
Community ID
Builder ID

Community
ID
Name
Quadrant ID

You seem to know exactly what you want. So what is the problem you’re encountering?

I have seen quite a few threads dealing with this issue, and you might find them using the term “query builder” - there could be other terms, but this ought to give you a start.

If you do not use PDO already, then that is also a good candidate for automating the filtering of incoming variable in such a query builder.

When it comes to doing joins however this can get fiddly, you might get some ideas by looking at how an ORM works, Doctrine is one example of an ORM.

@guido2004: I am just not sure the best way to get my dynamic variables from the form into a query, and how to build the query best.

mock up and show us a small example of your form with a couple of elements.