----- Original Message ----- From: Ming Xiao To: Julien Bonastre Sent: Friday, December 09, 2005 7:04 PM Subject: Re: Google Style Search Results hello everybody who knows ajax , I want to make a website use ajax technolgy. thanks,everybody! 2005/12/9, Julien Bonastre <julien@xxxxxxxxxxxxxxxx>: Sure, Firstly, thank you for the credit, that was only my second mid-scale project, coded ground up in Textpad 4 ;-) enough patting my own back, onto business.. http://aries.the-spectrum.org/webdev/wawd/forums/search.php?q=sufficient%2Blarge&st=post&sb%5B%5D=*&maxres=25&ob=datetime&ot=DESC Notice some changes?? You've just sparked a interest in me to revise and rewrite some of the code for that page this lovely 33 degree celcius summer Friday afternoon here in Australia.. :-) Previously, it was only really just pumping out the first sentence or so of text from the matched query.. Now though it is actually going through each query word and matching a set number of words surrounding it [in this case I've made it five] and throwing that out in the extraction field... with each of these said matches being seperated by a ellipsis [...] All I did was conjure up a regular expression that basically just matches words :-) haha ironically.. Here it is: $extract_result=""; preg_match_all("/((?:[\w]+ ?){0,5})[\w \.\,\-\;]((?:".join("|",$q_arr)."))([\w]*)[\w \.\,\-\;]((?:[\w]+ ?){0,5})/i",$row["content"],$ext_matches,PREG_SET_ORDER); foreach($ext_matches as $ext_arr) { $extract_result .= $ext_arr[1]." <B>".$ext_arr[2]."</B>".$ext_arr[3]." ".$ext_arr[4]." ... "; } Are you familiar with regex? It really shouldn't be hard to implement a similiar concept with whatever your current search system does.. My system as can be seen from this above code actually breaks up the query string sent via the form on search page into each word.. therefore you have an array [$q_arr] that looks like Array( "sufficient", "large") .. Hence in that regex above i just did a "join" using the "|" pipe symbol.. I use this so when it joins all the words together they come out as: word1|word2|word3 meaning regex will match 5 or less words before and after any of the given words. the | symbol means bitwise "OR", for example: run(ning|ner) will match running or runner but not runs Sorry if you already know some of this I am just trying to make sure I explain myself fully as I am unawares as to your experience level. Anyway, so yes I simply use the handy preg_match_all function which will run this regex statement upon the entire $row["content"] which in my case is just the entire content of the post which it found to match words in.. and from that it simply matches these certain given keywords and their surrounding word/s.. I then use a foreach structure to simply iterate over each of the matches and create the lovely string you see before you, it does this simply by reprinting the original matched string, creating a <B></B> bold effect on the given search word and adding an ellipsis at the end for simple athestic reasons.. If you want any more examples or clarification please feel free to ask.. Enjoy ;-) ---oOo--- Allowing users to execute CGI scripts in any directory should only be considered if: ... a.. You have no users, and nobody ever visits your server. ... Extracted Quote: Security Tips - Apache HTTP Server ---oOo--- ------oOo---------------oOo------ Julien Bonastre [The_RadiX] The-Spectrum Network CEO ABN: 64 235 749 494 julien@xxxxxxxxxxxxxxxx www.the-spectrum.org ------oOo---------------oOo------ ----- Original Message ----- From: < dpgirago@xxxxxxxxxxxxxx> To: "Julien Bonastre" <julien@xxxxxxxxxxxxxxxx> Sent: Friday, December 09, 2005 12:42 AM Subject: Re: Google Style Search Results > > Great site, Julien! Probably more involved than we need for our project, > but very, very impressive. I really like the CSS styling in particular. If > you could tell me how you are displaying the content within the "extract" > field, that would be very helpful. > > Regards, > > David > > > David P. Giragosian, Psy.D. > Database and Software Developer > 713-798-7898 > > > |---------+------------------------------------------> > | | | > | | | > | | "Julien Bonastre"| > | | <julien@xxxxxxxxxxxxxxxx>| > | | | > | | | > | | | > | | 12/08/2005 05:23 AM| > | | Please respond to "Julien| > | | Bonastre"| > | | | > | | | > |---------+------------------------------------------> > >-----------------------------------------------------------------------------------------------------------------| > | | > | | > | | > |To: | > | <dpgirago@xxxxxxxxxxxxxx> | > |cc: | > | | > | | > | | > | | > | | > |Subject: | > | Re: Google Style Search Results | > | | > >-----------------------------------------------------------------------------------------------------------------| > > > > > Try a quick visit to: > http://aries.the-spectrum.org/webdev/wawd/forums/search.php?q=done&st=post&sb%5B%5D > =*&maxres=25&ob=datetime&ot=DESC > > > If you are interested in that, I can tell you more.. > > ----- Original Message ----- > From: <dpgirago@xxxxxxxxxxxxxx> > To: <php-db@xxxxxxxxxxxxx> > Sent: Thursday, December 08, 2005 7:15 AM > Subject: Re: Google Style Search Results > > >> >> Thanks Joseph and Philip. I think that will work very well. >> >>>> why not use substr? >>>> $preview = substr($string, 0, 50) .'...'; >>>> >>>> it will probably cut off in the middle of a word, but you can use > strpos >>>> and >>>> check to see if the char is a space to get to the point you want. >>>> >>>> It's possible that the keywords wouldn't be in the first X numbers of >>>> characters. >> >>> Then use strstr() to find the first occurence of the first keyword and >>> then use substr with an initial offset... >> >> >> David >> >> -- >> PHP Database Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > > > > >