Seacrch text using php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vssp
    Contributor
    • Jul 2006
    • 268

    Seacrch text using php

    Hai friends

    I have got the contents from database But i need to search the content if any worsd available in the contents

    For example when I get the pargraph from the table then i find "Style" this word is avaliable in the paragraph .

    How can i find the text in the paragraph?

    _______________ ___
    Thanks
    Vssp
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Bit unclear, your question. Do you want to do a text search on certain columns in a table. You can do that with either a SELECT LIKE or a SELECT REGEXP (regular expression) function.

    Ronald :cool:

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      Using what Ronald said is ofc best so you dont get loads of data you dont need from the database.

      But if you want to use php to search throught the text there are lots of functions for that. strstr() for example

      [PHP]// Search for string
      if(strstr("need le", "heystack") )
      {
      // needle found. Do things!
      }
      else
      {
      // needle not found. Do other things.
      }[/PHP]

      Comment

      • theRamones
        New Member
        • Nov 2006
        • 13

        #4
        // list of words you want to find
        $list = array("Style", "href", "div"); // add it as u want

        $input = "aStylelkhRefs" ;
        for($i=0; $i< count($list); $i++)
        {
        if(eregi($list[$i], $input)) print "find $list[$i] in the $i list<br>";
        }

        Comment

        Working...