html - PHP Search Results display -
I am creating a basic search feature for my structure and how best to display search results ( Google Style) Returns the different pages based on my MYSQL query search query. The result from MySQL is correct, I need to do the following:
An example may be that someone searches for the word "Hello World", my search results will return all those rows "Hello "And" world "will both include
What I'm trying to achieve:
- Highlight the words in the search query, but only a piece of results I want to return only 200 characters and highlight the first occurrence of any word in the search term.
- The duplicate displayed is made in a CMS and has HTML tags in it. I am able to strip HTML tags before displaying it, but if I am doing it correctly then I have to get a response.
The code I am currently using is:
// query string: ("page results") AS $ results):? & Gt; // Clickable on the original page H3: & lt; H3 & gt; & Lt ;? = $ This- & gt; HTML-> "$. $ [[Title]] result, array (" Controller "= & gt;" page "," verb "=>," viewer "," property " "= & Gt; array ($ result ['name'])))? & Gt; & Lt; / H3 & gt; & Lt ;? Php // Strip all HTML characters such that the content comes from the WYSIWYG editor: $ value = preg_replace ('/ / lt; [^ & gt;] * & gt; /', '', $ result [content ' ]); // Find the position within the text: $ position = stripos ($ value, $ q); // If a positive position, display 200 characters and start -100 from the first time ($ position == true) {$ string = substr ($ value, $ position - 100, 200); } And {$ string = "..."; ? & Gt; & Lt; P & gt; & Lt ;? = $ String? & Gt; & Lt; / P & gt; & Lt; Hour / & gt; & Lt ;? php endforeach; ? & Gt;
I have the main problem here:
- The search results may have returned the rows, even if the query string is not accurate (it will return as a result) If the column contains "Hello" and "World", while
stripos will only find "Hello World".
- I do not know the best way to wrap
& lt; Tag near the first occurrence of a word or phrase within the HTML tag> strong & gt; & lt; / strong & gt; tag. I feel that this can be a daunting task especially due to the problem of the incident. This feature, but if there is a nifty way to do that would be great :)
Also the idea will be appreciated!
I recommend you to read about
< P> This is the most (based on my opinion), while customizing the search function.
- I do not know the best way to wrap
- The search results may have returned the rows, even if the query string is not accurate (it will return as a result) If the column contains "Hello" and "World", while
Comments
Post a Comment