filter search

--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.

--

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

--20cf30051392ebc26804a136ada9--
Emiliano Boragina [ Mo, 18 April 2011 21:48 ] [ ID #2058323 ]

Re: filter search

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
Jim Giner [ Di, 19 April 2011 15:45 ] [ ID #2058365 ]

Re: filter search

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
Jim Giner [ Mi, 20 April 2011 02:41 ] [ ID #2058415 ]

Re: Re: filter search

On Tue, Apr 19, 2011 at 7:41 PM, Jim Giner
<jim.giner [at] albanyhandball.com> 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
Swincher [ Mi, 20 April 2011 17:19 ] [ ID #2058416 ]

Re: Re: filter search

Methinks you are correct. MAYBE I should have written the code too!
"Ken Kixmoeller" <kixjaguar [at] comcast.net> wrote in message
news:BANLkTinMme9wS1ZTrepum+FNmMsyWan3Wg [at] mail.gmail.com...
On Tue, Apr 19, 2011 at 7:41 PM, Jim Giner
<jim.giner [at] albanyhandball.com> 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
Jim Giner [ Mi, 20 April 2011 19:05 ] [ ID #2058417 ]

Re: Re: filter search

--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 <jim.giner [at] albanyhandball.com>

> 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.
>



--

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

--20cf305e24c5c94efa04a15f4c40--
Emiliano Boragina [ Mi, 20 April 2011 22:16 ] [ ID #2058418 ]
PHP » gmane.comp.php.database » filter search

Vorheriges Thema: the source command worked...the table is restored but still problem displayed
Nächstes Thema: Re: RE£º[PHP-DB] How do I do math with a