Jump to content

etocaj

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Everything posted by etocaj

  1. Thanks for the help, I added in what you suggested but I'm unsure why it is not working. Here is what I did with the code you gave me: echo "<table align='left' width='685' bordercolor='ccc' border='1'>"; echo "<tr><td><strong>Date</strong></td><td><strong>MPSAS</strong></td><td><strong>NELM</strong></td><td><strong>Temp (C)</strong></td></td>"; $dir='./sqmpro/'; $files=scandir("$dir"); $array=array(); foreach($files as $file) { if ($file != '.' && $file != '..') { $ft=filemtime("$dir$file");//returns last modified timestamp $array[$file]=$ft; } } natsort($array); $array=array_flip($array); $last_file=array_pop($array); $content=file("$file"); for ($i = count($content) - 1; $i >=1 ; $i--) { $row = explode(",", $content[$i]); echo "<tr><td>{$row[0]}</td><td>{$row[1]}</td><td>{$row[2]}</td><td>{$row[7]}</td></td>";}echo "</table>"; ?> I basically took out this line and replaced it with your code $file = "myfile.csv" Where am I going wrong?
  2. I thought I had wrapped this project up, but found out that the program I use to FTP a csv file to my website is best used in time stamp mode. That is, each day a newly named csv file is uploaded with that days data. I currently have this script that I use to display the data on my website: PHP Code: echo "<table align='left' width='685' bordercolor='ccc' border='1'>"; echo "<tr><td><strong>Date</strong></td><td><strong>MPSAS</strong></td><td><strong>NELM</strong></td><td><strong>Temp (C)</strong></td></td>"; $file = "myfile.csv"; $content=file("$file"); for ($i = count($content) - 1; $i >=1 ; $i--) { $row = explode(",", $content[$i]); echo "<tr><td>{$row[0]}</td><td>{$row[1]}</td><td>{$row[2]}</td><td>{$row[7]}</td></td>";}echo "</table>"; ?> To read the most recent file I know I need to list the dir contents, sort, and then select the newest file, but I need some help getting started. Anyone have experience with that is willing to help me out? Thanks!
  3. Looks like the script is indeed updating properly. I tried the site from another computer at work and the data is changing on a refresh. I'm using array_multisort to try and get the most recent data to show at the top, but with no luck. Here is the code: echo "<table align='left' width='685' bordercolor='ccc' border='1'>"; $file = "myfile.csv"; $content=file("$file"); foreach($content as $line){$row=explode(",",$line); array_multisort($row[0], SORT_ASC, $content); echo "<tr><td>{$row[0]}</td><td>{$row[1]}</td><td>{$row[2]}</td><td>{$row[7]}</td></td>";} echo "</table>";?> I have never used array_multisort before so I'm stuck at this point. Anyone have any ideas? Thanks!
  4. This is the final code I used to get the table to format correctly: echo "<table align='left' width='685' bordercolor='ccc' border='1'>"; $file = "myfile.csv"; $content=file("$file"); foreach($content as $line) { $row=explode(",",$line); echo "<tr><td>{$row[0]}</td><td>{$row[1]}</td><td>{$row[2]}</td><td>{$row[7]}</td></td>"; } echo "</table>"; ?> I realized that this script will not update again on a browser refresh for some reason. I copied it into a page as a part of a wordpress theme, but the table did not update. The csv file is automatically sent to my web hosting server every minute so i know that it should include new data. Is there something else that needs to be included in the code to get this script to run again on a browser refresh? I know it is not a cache issue since I cleared it out. I also looked at the page on a different computer. Also, is it possible to have the table show the most recent data first? As it is now, you would have to scroll down the table to see the latest readings. Again, thanks for your help with this script!
  5. Great, that worked, except columns 1,2, and 7 were all overlapped on one another. I simply changed this line by adding <table></table> echo "[b]<table>[/b]<tr><td>{$row[0]}</td><td>{$row[1]}</td><td>{$row[2]}</td><td>{$row[7]}</td></tr>[b]</table>[/b]"; It looks pretty good now, maybe just some tweaking to the table spacing, etc. Thanks for the help!
  6. I have a basic script that I'm using to display raw data from a csv file on a website: <?php $file = "myfile.csv"; $fh = fopen($file, "rt"); $userdata = fread($fh, filesize($file)); fclose($fh); echo $userdata; ?> The csv file header looks like this: Date/Time,MPSAS,NELM,SerialNo,Protocol,Model,Feature,Temp© What I need is a simple four column table with Data/Time, MPSAS, NELM, and Temp © displayed. The other columns are not needed. I have searched the forum for an answer but to no avail. Any help would be greatly appreciated! Thanks for the help.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.