Fungsi highlightingnya:

        function google_hilite($text) {
        global $escapeEreg;
         $ref = urldecode($_SERVER[HTTP_REFERER]);
//       $ref = urldecode("http://www.google.com/?q=gw%20i";);


                # let's see if the referrer is google
          if (preg_match('/^http:\/\/w?w?w?\.?google.*/i',$ref)) {

                # if so, tweezer out the search query
           $query = preg_replace('/^.*q=([^&]+)&?.*$/i','$1',$ref);

                # scrub away nasty quote marks
           $query = preg_replace('/\'|"/','',$query);

                # chop the search terms into an array
           $query_array = preg_split ("/[\s,\+\.]+/",$query);
         
                # loop through the search terms
           foreach($query_array as $b){
           $b = strtr($b, $escapeEreg);

            if (!preg_match('/<.+>/',$text)) {

                # If there are no tags in the text, we'll just do a simple 
search and replace
             $text = preg_replace('/(\b'.$b.'\b)/i','<span
class="hilite">$1</span>',$text);

            } else {

                # If there are tags, we need to stay outside them
             $text = preg_replace('/(?<=>)([^<]+)?(\b'.$b.'\b)/i','$1<span
class="hilite">$2</span>',$text);

            }
           }
          }
          
          return $text;
         }


penggunaannya:

ob_start("google_hilite");

Taruh dimana saja di dalam script anda.

Note: baru nyala kalau diakses melalui google, jadi jgn bilang ngga
nyala ketika anda mengetesnya langsung.

Kalau searching, ya pinternya saja. Kalau saya sih cukup pakai LIKE
'%$input%' saja :)

Regards,


Natali Ardianto
[EMAIL PROTECTED]

On 7/1/05, arie <[EMAIL PROTECTED]> wrote:
> Halo..
> 
> Ada yang tau tutorial untuk buat search engine database mysql dengan php biar 
> bisa seperti di google gitu, dengan text highlight juga, ada yang tau script 
> tambahannya?
> 
> Makasih ya..




----------------------------------------------------------
Komunitas MasterWeb Indonesia http://www.master.web.id
----------------------------------------------------------
MWN, Masternya WEBHOSTING di Indonesia, Indo/USA Servers,
Customer Support 24 jam  http://www.masterwebnet.com
----------------------------------------------------------
WebDevelopment,Designing/Programming http://www.dlanet.com
---------------------------------------------------------- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/milis-masterweb/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Kirim email ke