Jump to content

Recommended Posts

Hi 

 

I trying the search using the query below:

 

$result = mysql_query("SELECT * FROM certificado WHERE nome='$name'  ") or die (mysql_error());
 
 
If I look for Jose da Silva in table,it only works if I type full name. "Jose da Silva" .

How can I make the query work by typing part of search string, as "Jose da", "Jose d", etc.
 
Moises
 


 
Link to comment
https://forums.phpfreaks.com/topic/281401-search-by-part-of-string/
Share on other sites

If searched for John and Elton John comes up, the search works, it wouldn't work so well otherwise.

 

If you needed more control and wanted to spend the time more advanced and multiple search queries, fulltext search is a better way.

http://dev.mysql.com/doc/refman/5.7/en/fulltext-search.html

 

Fulltext Boolean can do things matching against,within,excluding,stemming,weighted and so on.

http://dev.mysql.com/doc/refman/5.7/en/fulltext-boolean.html

If searched for John and Elton John comes up, the search works, it wouldn't work so well otherwise.

 

If you needed more control and wanted to spend the time more advanced and multiple search queries, fulltext search is a better way.

http://dev.mysql.com/doc/refman/5.7/en/fulltext-search.html

 

Fulltext Boolean can do things matching against,within,excluding,stemming,weighted and so on.

http://dev.mysql.com/doc/refman/5.7/en/fulltext-boolean.html

 

Also, maybe consider 'lastname', 'firstname' and 'middlename' columns.  Easier to concatenate those than try to guess a split on one column.

Very useful command, but if name is Elton John, and I search "John",   Elton John is found as well.

 

I need Elton John is found only if a type: "Elto"  "Elton" "Elton J", etc.

 

Moises

 

but...that's exactly what you said you wanted, yes?  If you want it to match starting at beginning of string, instead of anywhere within string, then remove the first %

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.