Page 1 of 1

Form based queries

Posted: Fri Jun 09, 2006 4:38 am
by parijke
Hi all,

We have a database which we want to expose to our users. That database is ment to be queried, but we want an interface upon that database so you can use certain attributes. We are examining if we can do that with php.

Is there some sort of framework out in the open (query builder or so) which can generate optimized SQL queries based upon user selections? So they can click their selecion criteria in a form or so.

Any advice is appreciated.

gr,
Paul

Posted: Fri Jun 09, 2006 6:14 am
by s.dot
If you want to build this yourself, a series of if/else/elseif statements would be the way to go. Gradually building your SQL query.

An example:

Code: Select all

$sqlQuery = 'SELECT * FROM `table` WHERE';

if($_POST['somecriteria'] == $sampleValue){

   $sqlQuery .= " `somefield` = '$someValue";

} else {

   $sqlQuery .= " `somefield` = '$someOtherValue";

}

echo $sqlQuery;

Not exactly what I meant

Posted: Fri Jun 09, 2006 7:06 am
by parijke
Well, thanks for the help but...

I need a little more than that I'm affraid. The idea is that a frontend is able to get the criteria from the user. So they type in postal code froM: .... till .....

We have about 20 attributes to search on, and they can search for more than one criteria.

Those selections must be saved for later adjustments

I think this is done before, so I post my question here. I found something that has a basic idea of mhat I want, call qmaker from Jay Narain.