954,598 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Site to display file contents?

Good Evening everyone,

I am hoping this is the proper place to post this question, might not be but im not really sure where to go with this one. I am working on a website for my company which will be based on our Intranet, and was wondering if there is a way for a page to display file contents.

Example. User runs a report that and comes up with user statistics. (excel document most likely) They would drop the file into /folder/folder/file.xls The website would take the contents of file.xls and display it on the website, this way each day the file is updated, the page will display the new stats.

Any help would be appreciated. Any questions just let me know.

Thanks in advance!

rcdeck
Newbie Poster
14 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

html wont be able to do this but php5+ could.

What you would need to do is to import it into mysql through phpmyadmin. You could then use php to present the data.

whiteyoh
Posting Pro in Training
479 posts since Jun 2009
Reputation Points: 15
Solved Threads: 15
 

depends on the complexity of the data, and whether you expect to be able to manipulate it online
If the importand information is a static table of information its a piece of cake
have the script that creates the report output it to a .csv file, with the correct name (same name every day)
a php script to display the datafile as a table

<!-- other html -->
<table border="0" cellpadding="0" cellspacing="1">
<?php $row = 1;
$handle = fopen("dailyreport.csv", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
 $num = count($data);
 $row++;
if ($row == 2) {
 echo "<thead>\n<tr>\n";
  for ($c=0; $c < $num; $c++) 	{  echo "<th >" . $data[$c] . "</th>\n";  }
echo "</tr>\n</thead>\n<tbody>"; 
}
else {
echo "<tr>\n";
for ($c=0; $c < $num; $c++) {
echo "<td>" . $data[$c] . "</td>\n";
}
echo "</tr>\n";
}
}
fclose($handle); ?>
</tbody>
</table>
<!--other html -->


crappy code, but it runs
file upload scripts abound, the script above requires the upload script uploads "dailyreport.csv" to the same folder
security is not considered, but should be in any production version

almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You