filter search

filter search

am 18.04.2011 21:48:44 von Emiliano Boragina

--20cf30051392ebc26804a136ada9
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hello,

I have an mysql database, with columns: id, name, day, month, year (this
last three birthdate), city,
I must to do a finder with filter.
This finder (or searcher) must can filter three thing: name, city and age.

I understand to do a finder with LIKE.
But I dont understand how or what I must to do to add the AND conditional,
and the WHERE.

I can do: query =3D "SELECT * FROM mydatabase WHERE name LIKE '%keyword%' A=
ND
city LIKE '%keyword%' ORDER BY id DESC"

I dont know how to do the AGE part and the conditionals AND if the user can
search one or two or three filters.

Thanks a lot.

--=20

------------------------------------------
Emiliano Boragina
desarrollos + comunicaci=F3n
------------------------------------------
+ 15 33 92 60 02
=BB emiliano.boragina@gmail.com
------------------------------------------
=A9 2011
------------------------------------------

--20cf30051392ebc26804a136ada9--

Re: filter search

am 19.04.2011 15:45:27 von Jim Giner

First - I would change "day,month,year" to a date field called 'birthdate'.

Then on the screen that the user chooses what to search for you let them
enter 1 or 2 or 3 values: the 'name', the 'city' or the 'age' (in years).

Then when you process that input, you determine what they entered - 1 or 2
or 3 things and build a WHERE clause based on 1 or 2 or 3 things.

For the Age filter you take it and subttract it from today's date (call it
'filterdate') and use the resulting date to say "birthdate >= filterdate"

Once you have your where clause built, you build your query and add the
where clause to it, like this:

$query = "SELECT * FROM $mydatabase WHERE $my_where_clause ORDER BY id DESC"




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: filter search

am 20.04.2011 02:41:35 von Jim Giner

No follow-up? I must have made complete sense!! :)



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Re: filter search

am 20.04.2011 17:19:02 von Swincher

On Tue, Apr 19, 2011 at 7:41 PM, Jim Giner
wrote:O
> No follow-up? =A0I must have made complete sense!! =A0:)

Either that or (based on the initial post) he had *no* idea what you
were talking about.

Ken

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Re: filter search

am 20.04.2011 19:05:29 von Jim Giner

Methinks you are correct. MAYBE I should have written the code too!
"Ken Kixmoeller" wrote in message
news:BANLkTinMme9wS1ZTrepum+FNmMsyWan3Wg@mail.gmail.com...
On Tue, Apr 19, 2011 at 7:41 PM, Jim Giner
wrote:O
> No follow-up? I must have made complete sense!! :)

Either that or (based on the initial post) he had *no* idea what you
were talking about.

Ken



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Re: filter search

am 20.04.2011 22:16:29 von Emiliano Boragina

--20cf305e24c5c94efa04a15f4c40
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Jim, thanks for your help...
I send because the first emial was replied saying to send again to see if I
am a spamer...
Thanks again.

2011/4/20 Jim Giner

> oh - and by the way - don't email people directly. We are all reading
> the list, so send your mail to the list and not to everybody as well.
>



--=20

------------------------------------------
Emiliano Boragina
desarrollos + comunicaci=F3n
------------------------------------------
+ 15 33 92 60 02
=BB emiliano.boragina@gmail.com
------------------------------------------
=A9 2011
------------------------------------------

--20cf305e24c5c94efa04a15f4c40--