Reply
Searching Database...
Old 07-09-2004, 03:46 PM Searching Database...
Unknown.

Posts: 1,693
I want to have a script so people can search for members in the database..

So they will be searching the field 'Username'...

I want it so if they seach for a name and it displays similar results...

So if they search R it will display all names begining with R...

So it would be something like...

Select * from Members Where Username is like '$Seacrh_value'

Anyone know the correct coding

Thanks

-James
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 07-09-2004, 03:55 PM
Republikin's Avatar
Super Moderator

Posts: 3,191
I am at work right now so I can't get too detailed but I might later if you still need help but look into mysql's full text searching
Republikin is offline
Reply With Quote
View Public Profile
 
Old 07-09-2004, 03:55 PM
compmodder26's Avatar
Experienced Talker

Posts: 44
You were really close with the example you had

try using:

"SELECT * FROM Members WHERE Username LIKE '$Search_value'"

you can also use '%' as a wildcard anywhere in the string. Wildcards are missing letters in the pattern. The server will accept any letter in place of '%'. So if you have 'R%' it would match anything that begins with a R. Let me know if you need anything else
compmodder26 is offline
Reply With Quote
View Public Profile Visit compmodder26's homepage!
 
Old 07-09-2004, 04:19 PM
Unknown.

Posts: 1,693
Thanks

How would i set it so if the user searched Jo it would display all users who have Jo somewhere in their username like.. John, Joe, Joseph and AklJo??

Thanks

-James
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Old 07-09-2004, 04:28 PM
compmodder26's Avatar
Experienced Talker

Posts: 44
Let's say;

$Search_value = "Jo";

Then you would do:

"SELECT * FROM Members WHERE Username LIKE
'%$Search_value%'"

When you place the '%' on either side of the search term it will match any character that is before and after it. As long as the search term is somewhere in the word then it will return result.
compmodder26 is offline
Reply With Quote
View Public Profile Visit compmodder26's homepage!
 
Old 07-09-2004, 04:54 PM
Unknown.

Posts: 1,693
Thanks

-James
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Old 07-09-2004, 04:57 PM
Republikin's Avatar
Super Moderator

Posts: 3,191
LIKE is easy to use and very tempting but you will get much more relevant results with full text searching. You can even order the results by the relevance in natural language.
Republikin is offline
Reply With Quote
View Public Profile
 
Old 07-09-2004, 06:40 PM
Unknown.

Posts: 1,693
Quote:
Originally Posted by cptnwinky
LIKE is easy to use and very tempting but you will get much more relevant results with full text searching. You can even order the results by the relevance in natural language.
Got any examples or know any good tutorials?

Thanks

-James
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Old 07-09-2004, 10:28 PM
Republikin's Avatar
Super Moderator

Posts: 3,191
http://dev.mysql.com/doc/mysql/en/Fulltext_Search.html

This should give you all the info you need to get started.
Republikin is offline
Reply With Quote
View Public Profile
 
Old 07-09-2004, 11:58 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
PHP and Unicode with UTF-8
Posts: 3,111
Location: Toronto, Ontario
Note that MySQL 3.23.23 does not support fulltext searching, the minimum version is 4.0.1. (A lot of hosts still have not upgraded to MySQL 4, so beware if you plan on distributing your script.)
Christopher is offline
Reply With Quote
View Public Profile Visit Christopher's homepage!
 
Old 07-10-2004, 08:26 AM
Republikin's Avatar
Super Moderator

Posts: 3,191
Chris, always the pecimist
Republikin is offline
Reply With Quote
View Public Profile
 
Old 07-10-2004, 11:43 AM
Christopher's Avatar
Iced Cap

Latest Blog Post:
PHP and Unicode with UTF-8
Posts: 3,111
Location: Toronto, Ontario
Me a pessimist? Naw.
Christopher is offline
Reply With Quote
View Public Profile Visit Christopher's homepage!
 
Old 07-10-2004, 06:38 PM
Unknown.

Posts: 1,693
Thanks for the advice

-James
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Searching Database...
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.18699 seconds with 12 queries