[PHP-DB] full text search
I have a question about full text search using mysql and php. There is text or html file data inside mysql, then I would like to search text from these file. when I filed some text inside text box in web site. mysql colum has below b_col_id, b_col, file_name I have wrote the code; ---header.html--- img src=img/seek.gifstyle=position:absolute;top:95px;left:600px alt=search form method=getaction=documentview.php input type=text name=pattern style=position:absolute;top:100px;left:650px input type=submit name=submit value=Searchstyle=position:absolute;top:100px;left:800px;border: 1px solid;boder-color:#663366nbsp; /form --part of documentview.php-- class seek{ function file_read($pattern){//retrieve_binary if($pattern){ $sql_select = SELECT * FROM view WHERE b_col = '$pattern'; $result = mysql_query($sql_select) or DIE (Could not perform SELECT in retrieve function .mysql_errno().: .mysql_error()); echo $result; if($result){ while ($temp = mysql_fetch_assoc($result)) { $filename = $temp['file_name']; $fileType = $temp['file_type']; $fileContent = $temp['b_col']; header(Content-type: $fileType); header(Content-Disposition: attachment; filename=$filename); header(Content-Description: PHP Generated Data); echo $fileContent; } exit; } else { print There is more then one record with that name or record does not exist!; } } }//end function file_read }// end of class seek if ($pattern){ //print($pattern br); $obj1 = new seek(); $obj1-file_read($pattern); exit; } - if anyone knows how to search text inside mysql database when I input text box from web, please teach me how! Regards, Yui -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] full text search
http://dev.mysql.com/doc/mysql/en/fulltext-search.html also.. i just use a LIKE in you sql statement On 8/11/05, Yui Hiroaki [EMAIL PROTECTED] wrote: I have a question about full text search using mysql and php. There is text or html file data inside mysql, then I would like to search text from these file. when I filed some text inside text box in web site. mysql colum has below b_col_id, b_col, file_name I have wrote the code; ---header.html--- img src=img/seek.gifstyle=position:absolute;top:95px;left:600px alt=search form method=getaction=documentview.php input type=text name=pattern style=position:absolute;top:100px;left:650px input type=submit name=submit value=Searchstyle=position:absolute;top:100px;left:800px;border: 1px solid;boder-color:#663366nbsp; /form --part of documentview.php-- class seek{ function file_read($pattern){//retrieve_binary if($pattern){ $sql_select = SELECT * FROM view WHERE b_col = '$pattern'; $result = mysql_query($sql_select) or DIE (Could not perform SELECT in retrieve function .mysql_errno().: .mysql_error()); echo $result; if($result){ while ($temp = mysql_fetch_assoc($result)) { $filename = $temp['file_name']; $fileType = $temp['file_type']; $fileContent = $temp['b_col']; header(Content-type: $fileType); header(Content-Disposition: attachment; filename=$filename); header(Content-Description: PHP Generated Data); echo $fileContent; } exit; } else { print There is more then one record with that name or record does not exist!; } } }//end function file_read }// end of class seek if ($pattern){ //print($pattern br); $obj1 = new seek(); $obj1-file_read($pattern); exit; } - if anyone knows how to search text inside mysql database when I input text box from web, please teach me how! Regards, Yui -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Joe Harman - Do not go where the path may lead, go instead where there is no path and leave a trail. - Ralph Waldo Emerson
Re: [PHP-DB] full text search in mysql
As of Version 4.0.1, MySQL can also perform boolean full-text searches I am running Mysql 3.x . This sounds like a simple task to me. Is it not implemented in 3.x? It does not have to be OR, NOR or anything, just AND I've never tried it, but you might be able to get away with SELECT columns FROM table WHERE MATCH (column) AGAINST ('caribbean') AND MATCH (column) AGAINST ('island'); I don't know if it'll work and it will probably be slow but... For more information, try reading http://www.mysql.com/doc/en/Fulltext_Search.html Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] full text search in mysql
I do get results for islands in greece as well. How can I specify in my statement, that both words have to be present? From the MySQL manual: As of Version 4.0.1, MySQL can also perform boolean full-text searches using the IN BOOLEAN MODE modifier. mysql SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE); Use + to indicate required words. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] full text search in mysql
As of Version 4.0.1, MySQL can also perform boolean full-text searches I am running Mysql 3.x . This sounds like a simple task to me. Is it not implemented in 3.x? It does not have to be OR, NOR or anything, just AND merlin Larry E . Ullman [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] I do get results for islands in greece as well. How can I specify in my statement, that both words have to be present? From the MySQL manual: As of Version 4.0.1, MySQL can also perform boolean full-text searches using the IN BOOLEAN MODE modifier. mysql SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE); Use + to indicate required words. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] full text search in mysql
Hi fellowes, I am working on a full text search in php and mysql. It workes pretty good, with one exception. If two words are entered, I do get results for each words in seperate as well. Examle: carribean islands I do get results for islands in greece as well. How can I specify in my statement, that both words have to be present? Thanx for any hint on that, Merlin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Full text search
Hi guys can anyone point me to some resources with regard to doing full-text searches in php. I looked at the mySQL docs and there doesnt seem to be much there. TIA. Angelo
[PHP-DB] Full text search of mysql
Hello, I want to use mysql's full text search capabilities with two different tables. Can i join tables using full text search? I am using mysql 3.23.55 thanks Hardik __ Do you Yahoo!? Yahoo! Shopping - Send Flowers for Valentine's Day http://shopping.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] full text search and how to underline keyword in results
Hi there, I am trying to write a php script to perform a full text search on a mysql db. I do a match against... and it digs out some results out of the db. There are 2 problems: 1. How can I restrict the results to e.g. 100 characters, but to make sure the keyword is within this 100 characters? 2. Is it possible with php to underline the keyword inside the search results. This might be more tricky. Thank you for any help on that, Andy -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] full text search and how to underline keyword in results
Hi Andy, In answer to part two - here's a snippet of code I use to highlight relevant words in red - hope it helps to put you on the right track. for ($i=0; $i count($keywords); $i++) { $blurb = eregi_replace( .$keywords[$i]. , font color=\#FF\.$keywords[$i]./font , $blurb); } where $keywords is an array containing all the words searched for and $blurb is the snippet that is returned with the search results At this stage in the flow, I've already retrieved relevant records - this is in fact the last step before I format and display the results.. Hope this helps stuart - Original Message - From: andy [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, August 25, 2002 9:32 PM Subject: [PHP-DB] full text search and how to underline keyword in results Hi there, I am trying to write a php script to perform a full text search on a mysql db. I do a match against... and it digs out some results out of the db. There are 2 problems: 1. How can I restrict the results to e.g. 100 characters, but to make sure the keyword is within this 100 characters? 2. Is it possible with php to underline the keyword inside the search results. This might be more tricky. Thank you for any help on that, Andy -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] full text search and how to underline keyword in results
for ($i=0; $i count($keywords); $i++) { $blurb = eregi_replace( .$keywords[$i]. , font color=\#FF\.$keywords[$i]./font , $blurb); } Hello Stuart, great, thats a first success and works fast. There are just 2 things which fail on this function: 1. Problems with full stops. A word with a full stop will be ignored (e.g singapore. will not be found if you search for singapore) 2. If you search for singapore and there is a hit Singapore (notice the capital!) will be replaced with singapore in the text. I tryed to fix that, but I fear that my php experiance lacks on this stage :-( Maybe someone else or you do have a idea for a fix? Cheers Andy Stuart McDonald [EMAIL PROTECTED] schrieb im Newsbeitrag 001901c24c45$2a5e6940$0100a8c0@stuart">news:001901c24c45$2a5e6940$0100a8c0@stuart... Hi Andy, In answer to part two - here's a snippet of code I use to highlight relevant words in red - hope it helps to put you on the right track. for ($i=0; $i count($keywords); $i++) { $blurb = eregi_replace( .$keywords[$i]. , font color=\#FF\.$keywords[$i]./font , $blurb); } where $keywords is an array containing all the words searched for and $blurb is the snippet that is returned with the search results At this stage in the flow, I've already retrieved relevant records - this is in fact the last step before I format and display the results.. Hope this helps stuart - Original Message - From: andy [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, August 25, 2002 9:32 PM Subject: [PHP-DB] full text search and how to underline keyword in results Hi there, I am trying to write a php script to perform a full text search on a mysql db. I do a match against... and it digs out some results out of the db. There are 2 problems: 1. How can I restrict the results to e.g. 100 characters, but to make sure the keyword is within this 100 characters? 2. Is it possible with php to underline the keyword inside the search results. This might be more tricky. Thank you for any help on that, Andy -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] full text search and how to underline keyword in results
andy, I find the PCRE regex option easier to work with. Herewith a solution which takes care of case (without changing the original text), and without regard to spaces or other characters (including the first and last characters of the string - which you didn't mention/identify as potential problems earlier!). You will observe the 'manufactured' the text string and that the found 'needles' are post-processed only by surrounding them with ampersands instead of your font tags - to prove that the regex works. Trust it suits. $RegExIn = Singapore singapore singapore. Singapore. singapore; $RegExPattern = |(singapore)|i; echo brReplaced: . preg_replace( $RegExPattern, $0, $RegExIn ) . ~; Regards, =dn for ($i=0; $i count($keywords); $i++) { $blurb = eregi_replace( .$keywords[$i]. , font color=\#FF\.$keywords[$i]./font , $blurb); } great, thats a first success and works fast. There are just 2 things which fail on this function: 1. Problems with full stops. A word with a full stop will be ignored (e.g singapore. will not be found if you search for singapore) 2. If you search for singapore and there is a hit Singapore (notice the capital!) will be replaced with singapore in the text. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] full text search and how to underline keyword in results
Yeah I had the same problem - also with question marks, quotes etc - I couldn't figure out a fix for it - if you do - please lemme know! cheers stuart - Original Message - From: andy [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, August 25, 2002 11:40 PM Subject: Re: [PHP-DB] full text search and how to underline keyword in results for ($i=0; $i count($keywords); $i++) { $blurb = eregi_replace( .$keywords[$i]. , font color=\#FF\.$keywords[$i]./font , $blurb); } Hello Stuart, great, thats a first success and works fast. There are just 2 things which fail on this function: 1. Problems with full stops. A word with a full stop will be ignored (e.g singapore. will not be found if you search for singapore) 2. If you search for singapore and there is a hit Singapore (notice the capital!) will be replaced with singapore in the text. I tryed to fix that, but I fear that my php experiance lacks on this stage :-( Maybe someone else or you do have a idea for a fix? Cheers Andy Stuart McDonald [EMAIL PROTECTED] schrieb im Newsbeitrag 001901c24c45$2a5e6940$0100a8c0@stuart">news:001901c24c45$2a5e6940$0100a8c0@stuart... Hi Andy, In answer to part two - here's a snippet of code I use to highlight relevant words in red - hope it helps to put you on the right track. for ($i=0; $i count($keywords); $i++) { $blurb = eregi_replace( .$keywords[$i]. , font color=\#FF\.$keywords[$i]./font , $blurb); } where $keywords is an array containing all the words searched for and $blurb is the snippet that is returned with the search results At this stage in the flow, I've already retrieved relevant records - this is in fact the last step before I format and display the results.. Hope this helps stuart - Original Message - From: andy [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, August 25, 2002 9:32 PM Subject: [PHP-DB] full text search and how to underline keyword in results Hi there, I am trying to write a php script to perform a full text search on a mysql db. I do a match against... and it digs out some results out of the db. There are 2 problems: 1. How can I restrict the results to e.g. 100 characters, but to make sure the keyword is within this 100 characters? 2. Is it possible with php to underline the keyword inside the search results. This might be more tricky. Thank you for any help on that, Andy -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] full text search and how to underline keyword in results
The first argument passed to eregi_replace is .$keywords[$i]. You are concatenating the string and a space on the end and front. This was obviously used as a hack to make sure only full words were highlighted. A fix for this? A simple hack would be to take out the spaces, so it is simply $keywords[$i], although you could figure out a proper regex if you don't want partial words higlighted. Adam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php