Jump to content

Search Question


phrozenflame

Recommended Posts

How do I create a simple to advanced search function. like a major website, how do they set up a search for a forum, or for a website or something of that nature.  What do I need to do, would it require a database, or wuold I try to store the whole website information into various variables, and pass it to one big function, with a form text area, and get it to search through all the variables. Or do I pick specific keywords, like what I think they would want to search for, and pass each to a variable in there location, and then create a function for a form text area, to where if they type in one of the words it somehow draws the page with that variable up There has to be some ways,  Main thing is does it involve a database if not then how would I go about doing this
Link to comment
https://forums.phpfreaks.com/topic/32227-search-question/
Share on other sites

If you really want to get a start, dont think so much. 8) , the easiest way to perform a search is through the mysql database, you search it by catagorizing it, forexample see the table below:

[table][tr][td]Name [/td][td]Type[/td][td]Price[/td][/tr]
[tr][td]Apples[/td][td]Fruits [/td][td]3[/td][/tr]
[tr][td]Paper[/td][td]Comedity[/td][td]1[/td][/tr]
[tr][td]Orange[/td][td]Fruites[/td][td]4[/td][/tr][/table]

you can use mysql quries to group them by types so that the results will show only the fruits or the comdities. or you can search by percentage match which is this >>>% symbol, I am not perticularly sure how you use it, but yeah, mysql search should be the easiest.
Ted
Link to comment
https://forums.phpfreaks.com/topic/32227-search-question/#findComment-149583
Share on other sites

SELECT * FROM your_table WHERE match_field LIKE 'S%'  // will find all items beginning with S,

SELECT * FROM your_table WHERE match_field LIKE '%Z'  // will find all items ending with Z,

SELECT * FROM your_table WHERE match_field LIKE '%abc%' // will find all occurences of abc.. e.g. 123abc456, or abcdefg, or 123abc

If you are wanting search capabilities, MySql is the way to go. You can let mysql do the work for you instead of trying to use PHP and match strings

Link to comment
https://forums.phpfreaks.com/topic/32227-search-question/#findComment-149796
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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