Jump to content

Search - Textfield


yandoo

Recommended Posts

Hi there,

 

I need to build a search form that has a simple text field that the user can use to search a table in my database. The drop down options would be used to determine what field in the table you are searching....

 

Could somebody point me in the direction of a good tutorial or where i can find out how to build this please??

 

Thanks

Link to comment
Share on other sites

Use InnoDB (i think) table format and then add a fulltext index to the fields you want to be able to search. You'll need to find a bit more information on this as its been a while since i did this but something like

SELECT *,search FROM `table` WHERE MATCH('text_field_input') AGAINST(`field`) AS `search` ORDER BY `search` DESC;

 

This (should, again, been a while, you might have to play with the syntax) will take your input, match it against a field and display the results from the highest matched percentage to the lowest (out of 1, * by 100 if you want actual percentage to display).

Link to comment
Share on other sites

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.