How to extract a matching phrase from data in MYSQL/PHP? -


I'm trying to implement the search functionality in my website. I have the following types of data

  Title Descr ----- ----- World News World News, World News, World Sports World Sports News, All People of the Game For now, the game is a famous world  

Now I want the user to search for "World News", the result will look like the following,

  World news (title) ... all world news events covered ... (descr)  

Actually I remember Want to display some phrases on a rudimentary basis. When a user searches for "world news" then for some time he will get results like above and sometimes below,

  world news (title) world news, news from around the world, (Descr)  

Please tell me how we can use such functionality mysql queries, or if it is not directly possible through mysql questions, how to use PHP Can be done

Google sometimes does the same thing, Google Rshit does is divides phrases in the middle and displays sometimes the initial text.

Thank you.

Not sure if there is a MySQL method to achieve what you receive . I will pull the field from the database and then use the PHP Explosion () function to make a phrase random:

$ desc_field_result = "World news, news from around the world, all the world News incidents covered "; // "Desc" field from your MySQL query $ desc_field_array = explosion (",", $ desc_field_result); $ Selected_desc = $ desc_field_array [RAND (0, size ($ desc_field_array -1)]; Echo $ selected_desc;

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -