advanced filtering

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
yshaf13
Forum Commoner
Posts: 72
Joined: Mon Apr 03, 2006 7:59 pm

advanced filtering

Post by yshaf13 »

Hi, Does anybody know of a script I can use for advanced filtering? I need to be able to filter by four or five different things or none at all or only some, and on top of that there has to be ordering.... It's a lot of work and I was just wondering if I can reuse someone's code since it's a pretty basic function of database driven sites...
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

What are you filtering?
(#10850)
yshaf13
Forum Commoner
Posts: 72
Joined: Mon Apr 03, 2006 7:59 pm

re

Post by yshaf13 »

i have kids in a camp.
I want to be able to filter by group, gender, age, incomplete profile, tests scores....
and after that i have to be able to order by name, group, .....
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

SQL is all about filtering results - that's the language you want to learn.
yshaf13
Forum Commoner
Posts: 72
Joined: Mon Apr 03, 2006 7:59 pm

Re:

Post by yshaf13 »

sorry for not being more specific. I know basic SQL and could probably write it up myself, but it's pretty tedious to write the code so that it looks through all the filtering data collected from the form and generate SQL based on that. I just thought maybe there is a code snippet out there somewhere that i could just reuse...
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

ah - what you're looking for is an ORM: "Object Relational Mapping"

Propel and Doctrine are the "big two", but there's a more exhaustive list here:
http://en.wikipedia.org/wiki/List_of_ob ... ftware#PHP
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

So for all the smart, jerky young boys whose parents fill out forms completely:

Code: Select all

SELECT * FROM kids WHERE group='brats' AND gender='M' AND age<10 AND incomplete_profile='No' AND test_scores>90
(#10850)
yshaf13
Forum Commoner
Posts: 72
Joined: Mon Apr 03, 2006 7:59 pm

re

Post by yshaf13 »

if you would like to see exactly what i need, go to kayak.com, do a search for anything and check out the filtering on the left side. i dont need all the fancy javascript, just the filtering....
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

They're showing and hiding results with javascript - I would assign each result a custom DOM attribute like "airline='xxx'" and select the node to hide/ show based on that. jQuery would make exceptionally short work of that.
Post Reply