PHP MySQL query results auto download pdf files
Posted on 2008-10-07
I have a mysql table called download. There are only 3 columms: id, filename, down
As pdf files are created and saved in a folder on the server called /files this table is updated.
The id is autoincrement
The filename is the filename of the pdf saved in the /files directory
The down column is initially set to 0, meaning that file has not been downloaded.
I have a PHP page that displays all of the filenames where down = 0, using the following query
"SELECT * FROM download WHERE downloaded = '0'"; and a repeating region for the table.
What I would like is to have a hyperlink that when clicked, automatically downloads all of the pdf files that meet the query, and then updates the table to make down = 1 for each of the files downloaded, so that they won't show up in the next page refresh.
I know how to do the update for the mysql table.
What I need help on is how to automatically download each pdf from the /files directory on the server to the clients computer that meets the down = 0 criteria