Re: Searching MS Word Docs
| From: | Nicole Amashta | Date: | Fri, 08 Feb 2002 21:17:50 +0000 |
| Subject: | Re: Searching MS Word Docs | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-11937@lists.php.net to get a copy of this message | ||
> > Aren't you suppose to do the array before doing the $numrows?
not in this case. Mysql already returned the number of rows, so i use the
mysql function to get the number of rows.
then, i use the result pointer to return a record as an array for each
record in the result set returned.
-nicole
"Todd Williamsen" <todd@williamsen.net> wrote in message
news:20020208211458.60845.qmail@pb1.pair.com...
> I tried that too, and it returns nothing
>
>
> "Nicole Amashta" <430ntr3k@bellsouth.net> wrote in message
> news:20020208211349.59771.qmail@pb1.pair.com...
> > >>while ($row = mysql_fetch_array($row))
> >
> > Sorry, that should be:
> >
> > while ($row = mysql_fetch_array($result))
> >
> > =[
> >
> >
> >
> > "Todd Williamsen" <todd@williamsen.net> wrote in message
> > news:20020208210540.52564.qmail@pb1.pair.com...
> > > Nicole
> > >
> > > It doesn't like this line:
> > >
> > > while ($row = mysql_fetch_array($row))
> > >
> > > Aren't you suppose to do the array before doing the $numrows?
> > >
> > >
> > > "Nicole Amashta" <430ntr3k@bellsouth.net> wrote in message
> > > news:20020208202629.26635.qmail@pb1.pair.com...
> > > > Of course, I was quick to send w/out checking for errors, so here
> again
> > is
> > > > corrected:
> > > >
> > > > ==================
> > > > <?
> > > >
> > > > ## do your code to connect to the db, etc....i'' leave this out
since
> > you
> > > > shoudl know what to do anyway. if not, let me know.
> > > >
> > > > ## now do the query
> > > > $query = "select filename from resume"; ## assuming resume is the
> > name
> > > of
> > > > table that stores name of the files of resumes posted
> > > > $result = mysql_query($query);
> > > >
> > > > if ( $result )
> > > > {
> > > > if ( ( $numrows = mysql_num_rows($result) ) > 0 )
> > > > {
> > > > while( $row = mysql_fetch_array($row) )
> > > > {
> > > > $filename = $row["filename"];
> > > > $fd = fopen($filename, "r");
> > > > $contents = fread($fd, filesize($filename));
> > > > fclose($fd);
> > > > $keyword = "$words"; #$words = the search word(s) from the
form
> > > > if ( eregi( $keyword, $contents) )
> > > > echo "The word <b>$keywords</b> has been found in the
resume
> "
> > .
> > > > basename($filename) . "<br>";
> > > > }
> > > > }
> > > > else {
> > > > echo "There are no resumes posted yet.";
> > > > }
> > > > }
> > > > else {
> > > > echo "Error performing the query.";
> > > > }
> > > >
> > > > ?>
> > > >
> > > > ==================
> > > >
> > > > "Nicole Amashta" <430ntr3k@bellsouth.net> wrote in message
> > > > news:20020208202309.21514.qmail@pb1.pair.com...
> > > > > IF $ResumeUp is the actual path and filename to the file you want
to
> > > > search,
> > > > > then that can work.
> > > > >
> > > > > For each file retrieved from your table, you can search the file
for
> > the
> > > > > keywords.
> > > > >
> > > > >
> > > > > Pretend you have the table called resume ( I am also assuming you
> are
> > > > using
> > > > > mysql database )
> > > > >
> > > > > create table resume(id int not null auto_increment primary key,
> > filename
> > > > > varchar(50), subdate datetime);
> > > > >
> > > > > ------------------------------------
> > > > > <?
> > > > >
> > > > > ## do your code to connect to the db, etc....i'' leave this out
> since
> > > you
> > > > > shoudl know what to do anyway. if not, let me know.
> > > > >
> > > > > ## now do the query
> > > > > $query = "select filename from resume"; ## assuming resume is
the
> > > name
> > > > of
> > > > > table that stores name of the files of resumes posted
> > > > > $result = mysql_query($query);
> > > > >
> > > > > if ( $result )
> > > > > {
> > > > > if ( $numrows = mysql_num_rows($result) > 0 )
> > > > > {
> > > > > while( $row = mysql_fetch_array($row)
> > > > > {
> > > > > $filename = $row["filename"]; ## this is the name
> > > > > of
> the
> > > > field
> > > > > returned from the query result.
> > > > >
> > > > > ## next, search through this file for the keywords
> > > > > $fd = fopen($filename, "r");
> > > > > $contents = fread($fd, filesize($filename));
> > > > > fclose($fd);
> > > > > $keyword = "$words"; /// $words = the search word(s) from
the
> > form
> > > > >
> > > > > if(eregi($keyword, $contents))
> > > > > echo "The word <b>$keywords</b> has been found in
> > > > > the
resume
> "
> > .
> > > > > basename($filename) . "<br>";
> > > > > }
> > > > > }
> > > > > else {
> > > > > echo "There are no resumes posted yet.";
> > > > > }
> > > > > }
> > > > > else {
> > > > > echo "Error performing the query.";
> > > > > }
> > > > >
> > > > > ?>
> > > > > ----------------------------------
> > > > >
> > > > > Of course, you can modify this code to how you want your output to
> be.
> > > You
> > > > > can also do a count to see how many resumes were found in the
> database
> > > > that
> > > > > have that word existing in the resume. And so on ....
> > > > >
> > > > > Need anymore help? Just let me know ....
> > > > >
> > > > > Nicole Amashta
> > > > > www.aeontrek.com
> > > > >
> > > > > ========================
> > > > >
> > > > > "Todd Williamsen" <todd@williamsen.net> wrote in message
> > > > >
> > > > > news:20020208200723.4947.qmail@pb1.pair.com...
> > > > > > ok... so for me I would do this... just wanted to confirm
it.....
> > > > > >
> > > > > > $filename = "$ResumeUp"; /// the file name variable stored
> > > > > > in
the
> > DB
> > > > > > $fd = fopen($filename, "r");
> > > > > > $contents = fread($fd, filesize($filename));
> > > > > > fclose($fd);
> > > > > > $keyword = "$words"; /// $words = the search word(s) from
> > > > > > the
form
> > > > > >
> > > > > > if(eregi($keyword, $contents))
> > > > > > echo "The Word $keywords has been found";
> > > > > >
> > > > > >
> > > > > > Now I am trying to figure out how to structure the query to
where
> it
> > > > > > searches all resumes that are posted...
> > > > > >
> > > > > > $sql = "SELECT * FROM $table WHERE ResumeUp =
> > > > > > \"$ResumeUp\"";
> > > > ///location
> > > > > of
> > > > > > file
> > > > > >
> > > > > > right?
> > > > > >
> > > > > >
> > > > > > "Nicole Amashta" <430ntr3k@bellsouth.net> wrote in
> > > > > > message
> > > > > >
> > > > > > news:20020208195906.99187.qmail@pb1.pair.com...
> > > > > > > Here is an example:
> > > > > > >
> > > > > > > ------------------------------------------
> > > > > > >
> > > > > > > $filename = "thefile.doc";
> > > > > > > $fd = fopen ( $filename, "r" );
> > > > > > > $contents = fread ( $fd, filesize($filename) ); ## contents
of
> > > file
> > > > > are
> > > > > > > now in a string
> > > > > > > fclose ($fd);
> > > > > > >
> > > > > > > ## now, since you have contents of file in string $contents,
you
> > can
> > > > use
> > > > > > > regex to search for keywords
> > > > > > >
> > > > > > > $keyword = "name";
> > > > > > >
> > > > > > > ## eregi is the non-case-sensitive way to search strings.
> > > > > > > ## you can also use the perl regex: preg_match so that you can
> use
> > > > > > perl-like
> > > > > > > regexes ( /$pattern/i ), etc.
> > > > > > >
> > > > > > > if( eregi( $keyword, $contents ) )
> > > > > > > echo "The word \"name\" has been
> > > > > > > found.<br>";
> > > > > > > else
> > > > > > > echo "The word \"name\" has not been
> > > > > > > found.<br>";
> > > > > > >
> > > > > > > ------------------------------------------
> > > > > > >
> > > > > > > Again, go to php.net and look up all the possible ways to
search
> > > > > strings.
> > > > > > >
> > > > > > > good luck,
> > > > > > > Nicole Amashta
> > > > > > > www.aeontrek.com
> > > > > > >
> > > > > > > "Todd Williamsen" <todd@williamsen.net> wrote in
> > > > > > > message
> > > > > > >
> > > > > > > news:20020208195034.90279.qmail@pb1.pair.com...
> > > > > > > > interesting... cool eh?
> > > > > > > >
> > > > > > > > i will give it a whirl...
> > > > > > > >
> > > > > > > > now I got to figure out the regex function
> > > > > > > >
> > > > > > > >
> > > > > > > > "Nicole Amashta" <430ntr3k@bellsouth.net>
> > > > > > > > wrote in message
> > > > > > > >
> > > > > > > > news:20020208194711.83171.qmail@pb1.pair.com...
> > > > > > > > > I made a test file in word. It's funky, but it
> > > > > > > > > still has
the
> > > > actual
> > > > > > text
> > > > > > > > in
> > > > > > > > > ascii. You should - just an assumption - be able to
> > > > > > > > > open
the
> > doc
> > > > > with
> > > > > > > php
> > > > > > > > > and read through the file doing a keyword search.
> > > > > > > > >
> > > > > > > > > Can't hurt to experiment with it.
> > > > > > > > >
> > > > > > > > > good luck,
> > > > > > > > > Nicole Amashta
> > > > > > > > > www.aeontrek.com
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > "Todd Williamsen" <todd@williamsen.net>
> > > > > > > > > wrote in message
> > > > > > > > >
> > > > > > > > > news:20020208193739.67610.qmail@pb1.pair.com...
> > > > > > > > > > Nicole,
> > > > > > > > > >
> > > > > > > > > > I have no idea if its ASCII formatted or not. I
> > > > > > > > > > wonder
if
> > > there
> > > > > is
> > > > > > a
> > > > > > > > way
> > > > > > > > > to
> > > > > > > > > > find out?
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > "Nicole Amashta"
> > > > > > > > > > <430ntr3k@bellsouth.net> wrote in
message
> > > > > > > > > >
> > > > > > > > > > news:20020208193201.49760.qmail@pb1.pair.com...
> > > > > > > > > > > OK, I am not exactly sure of the format of
> > > > > > > > > > > word docs
off
> > > hand.
> > > > > But
> > > > > > > if
> > > > > > > > > they
> > > > > > > > > > > are an ascii format, you can just read
> > > > > > > > > > > through the
file
> > > using
> > > > > PHP
> > > > > > > and
> > > > > > > > > use
> > > > > > > > > > > regular expressions to search for the words.
> > > > > > > > > > > Just a
> > > > suggestion.
> > > > > > > > > > >
> > > > > > > > > > > That's just if it's ascii format.
> > > > > > > > > > > Read the whole file
> into
> > a
> > > > > > string,
> > > > > > > > > then
> > > > > > > > > > > search the string with a regular expression
> > > > > > > > > > > function.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > http://www.php.net/manual/en/ref.regex.php
> > > > > > > > > > >
> > > > > > > > > > > Here is some help on regex's if you
> > > > > > > > > > > don't know
already.
> > > > > > > > > > >
> > > > > > > > > > > Nicole Amashta
> > > > > > > > > > > Web App. Dev.
> > > > > > > > > > > www.aeontrek.com
> > > > > > > > > > >
> > > > > > > > > > > "Todd Williamsen"
> > > > > > > > > > > <todd@williamsen.net> wrote in
message
> > > > > > > > > > >
> > > > > > > > > > > news:20020208192757.41472.qmail@pb1.pair.com...
> > > > > > > > > > > > I have an application in which I would
> > > > > > > > > > > > like to
search
> MS
> > > > Word
> > > > > > docs
> > > > > > > > > with
> > > > > > > > > > > PHP
> > > > > > > > > > > > and I am assuming with COM to perform
> > > > > > > > > > > > this. The
> > Documents
> > > > > > reside
> > > > > > > on
> > > > > > > > a
> > > > > > > > > > > Linux
> > > > > > > > > > > > box(for now). Now I want to be able to
> > > > > > > > > > > > search these
> > > > documents
> > > > > > > with
> > > > > > > > > > > > keywords.
> > > > > > > > > > > >
> > > > > > > > > > > > Is this possible? Where do I look to do
> > > > > > > > > > > > perform
this?
> > > Will
> > > > > COM
> > > > > > > run
> > > > > > > > > on
> > > > > > > > > > > > Linux or will php, mySQL will have to
> > > > > > > > > > > > reside on a
> > Windows
> > > > > > > > application?
> > > > > > > > > > > >
> > > > > > > > > > > > Thanks!
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>