Home > Archive > PHP SQL > September 2005 > php/mysql search
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| atlantic 2005-09-02, 6:57 pm |
| I'm trying to build a form where the user searches for a name, and then all
of the names that match are listed. I'd like both of these to appear on the
same page.
e.g. -
+-----------------+
Name: | Jimm | <Go>
+-----------------+
Would produce:
Jimmy Johnson
Jimmie Smith
Jimmbo White
Thanks for any input...
| |
| ZeldorBlat 2005-09-02, 6:57 pm |
| How are you storing the names? If you're using a database, a query
like this should do the trick:
select * from tbl_person where name like 'Jimm%'
| |
| Stefan Rybacki 2005-09-03, 7:55 am |
| ZeldorBlat wrote:
> How are you storing the names? If you're using a database, a query
> like this should do the trick:
>
> select * from tbl_person where name like 'Jimm%'
>
That is one solution, but he should think about a fulltext index (and use MATCH AGAINST)
for the name field when the name count increases as well as he wants to search for last
names too.
Stefan
| |
| RootShell 2005-09-04, 6:56 pm |
| select * from tbl_person where name like '%Jimm%'
That way all Jimm's will appear even "John Jimmy" ;)
--
RootShell, Lisbon, Portugal, Europe, Earth ;)
To protect against spam, the address in the "From:" header is not valid.
In any case, you should reply to the group so that everyone can benefit.
If you must send me a private email, use -> RootShell AT netcabo DOT pt
| |
| Stefan Rybacki 2005-09-05, 3:55 am |
| RootShell wrote:
> select * from tbl_person where name like '%Jimm%'
>
> That way all Jimm's will appear even "John Jimmy" ;)
>
Yes and no index will be used, very good! ;)
And "Johnjimm" will also be found. However, I just said was to keep performance even on
big tables you could use a fulltext index if you also want to search for lastnames.
Stefan
|
|
|
|
|