One solution might be : opening PDF file as a regular file (with fopen() ), search through it
with strings search PHP functions, and then display a list of corresponding PDF files.
But it's obvious it can be really really slow, depending of number of files.
Instead, you can, at creation time, insert into a MySQL database keywords
corresponding to the newly created PDF file. When searching, it will just be
a "SELECT" statement inside an SQL database, which is really fast.
Something like this :
Table "files" :
+----+----------------------+
| id | url |
+----+----------------------+
| 1 | /files/pdf/file1.pdf |
| 2 | /files/pdf/file2.pdf |
| 3 | /files/pdf/file3.pdf |
|... | ... |
+----+----------------------+
Table "keywords" :
+----+---------+
| id | keyword |
+----+---------+
| 1 | cat |
| 2 | dog |
| 3 | fish |
|... | ... |
+----+---------+
Table of relation between files & keywords :
Table "rel_kw_files":
+---------+------------+
| id_file | id_keyword |
+---------+------------+
| 1 | 1 |
| 1 | 2 |
| 2 | 1 |
| 2 | 3 |
| ... | ... |
+---------+------------+
Which mean that :
To get the list of files corresponding to a
' $search_keyword ' (input via a HTML form) :
SELECT url
FROM files,keywords,rel_kw_files
WHERE (keywords.keyword = '$search_keyword') AND
(rel_kw_files.id_keyword = keywords.id) AND
(rel_kw_files.id_file = files.id)