I have a question and im wondering if someone can help with a solution.
Basically I have a bunch of files, they are word, excel and pdf documents, I also have a sql database which holds the first part of all these files, the database does not hold the exension of each file as it could be one of 3 filetypes.
For example I have 1 file called
in the database im simply holding the first part of the file, for the above example I hold in the sql database
I don't hold the extension of each file as it could be one of 3 file types
.doc - for word documents
.xls - for exel documents
.pdf - for pdf documents
So there is no point in putting helpme.pdf as the file could be a word document (.doc) or a excel (.xls) document.
I then have a php page which performs a query and returns the list of files stored in the sql database, the sql I use is
<? session_start(); include ("connect.php"); $sql ="SELECT * FROM files WHERE file = $file"; $result = @mysql_query($sql,$connection) or die(mysql_error()); $num = mysql_num_rows($result); ?>
I then print off the filenames using
<?php print "$rows[file]"; ?>
so a result page looks kind of like
What I want to do is to put a link next to each result to link to the file, so it looks like
helpme - link to file
guide - link to file
workflow - link to file
book - link to file
as the database does not know what the file extension is, can I php statement be written which checks a specified folder (which the files are stored in) and then check to see if there is file matching the result which ends in either
There will never be more then one file with the same name, ie. there is not a
there is only ever one file with the same name. The sql statement would need to find the file which just matches the first part of the filename.
Does that make any kind of sense to anyone? Can anyone help me?
Thanks in advance