![]() |
how to search the content of txt file
[code]input type="text" name="keyword"><input type="submit" name="search" value="Search>[code]
PHP Code:
george.txt content: a b c d e f g h i j k l m n o p q r s t u v w x y z totz.txt content: one two three four five six seven eight nine ten if i enter the word one in the input box and then click search, the display should be totz.txt. how would i do to make that posible..please give me an example |
While i do not recommend this, as it does not scale well at all, and you would be better off inputting the information to mysql and search using the FULLTEXT boolean/LIKE search tools over this method.. It IS possible however:
PHP Code:
|
oh!!thank u very much blue saga.i have tried also doing that but like what u said is not recommended..if i insert the data into my database like this one
PHP Code:
|
Change
file_get_contents('$row[path]') to file_get_contents($row['path']). |
ok.thanks salathe.i have 1 problem.if i have a doc type file and i want to open it i should convert it first to txt.my problem is i dont know a script that convert doc to txt.i saw on internet this code
[php] $word = new COM("word.application") or die("Unable to instantiate Word"); $word->Documents->Open($filename); $new_filename = substr($filename,0,-4) . ".txt"; // the '2' parameter specifies saving in txt format $word->Documents[1]->SaveAs($new_filename,2); $word->Documents[1]->Close(false); $word->Quit(); $word->Release(); $word = NULL; unset($word); $fh = fopen($new_filename, 'r'); $contents = fread($fh, filesize($new_filename)); fclose($fh); unlink($new_filename); [php] i tried to run this but theres an error on it class COM is not defined what does that mean? |
It means the class is not defined, ie doesn't exist. You need to have all the files that come with the script.... Check PHP classes.
http://www.phpwordlib.motion-bg.com/ looks good. |
COM is a part of the PHP core (formerly a PHP extension before PHP5) for Windows, to allow working with external programs. Since you're getting the "not defined" error then you're either not on Windows or are using PHP4 without the COM extension installed. Using the COM, as in the example code that you posted, allows PHP to actually talk to Word itself, directly, rather than just manipulating the doc file in PHP.
Edit: Here's a link to the COM Documentation in the PHP manual. |
News to me, thanks for that Salathe :)
|
thanks guys..really help me.i will check it out..thank you
|
if i have a linux platform is it posible to run the COM if i will install wine and ms office?or its for windows platform only?
|
I would not say this is an ideal efficient method of doing this programming.
I would recommend getting a php only class that is not reliant on external sources. |
ok thanx guys.
|
| All times are GMT. The time now is 02:17 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0