I have numerous .csv files from a statistics export program that I would like displayed in tables on my php site. An example of what I would like on my site is here . There are many .csv files that all link together.
What I am trying to do is create a statistics page much like you would see on espn.com where you can see team stats, then click on teams for individual stats etc. These stats would be updated nightly preferably automatically which the program permits. If you click around on the link you will see what I mean. I am very new at php, barely getting this site up and running. Any help would be VERY appreciated.
Los Angeles,18,14,1,3,31,.861,61,41,14,94,14.9,2,10,101,90.1,3
Buffalo,17,14,2,1,29,.853,59,30,16,62,25.8,1,6,61,90.2,3
NY Rangers,22,14,8,0,28,.636,66,64,18,126,14.3,2,10,130,92.3,2
Anaheim,18,13,3,2,28,.778,75,62,18,74,24.3,0,15,59,74.6,1
Montreal,19,12,4,3,27,.711,66,49,14,65,21.5,3,10,67,85.1,3
You can put in a counter or use a for loop instead of the inner foreach and give that cell a class name and use a stylesheet to change its color like the one in your sample. I've tested this code and it works.
This code would probably be called in another loop that fed a list of files to it to be converted effectively handling your many files strung together thing.
If you are interested I'd be happy to finish it out for you. Just send me a Private Message on this forum.
__________________
"Things are difficult only while you don't understand them."
What exactly do you need help doing? Since your files/data and web site is unique, this would require custom programming. The code to do this would need to know the file naming scheme, the format of the data within each file, and where, when, and what format to output the data on a page.
This problem is basically, open, read, and parse the proper file at the proper point on the web page and output the contents in the format you want. Since you have not supplied any specific detail, you are not going to get a specific response, only more questions.
The example that grafman posted gives typical code that would read a specific file with csv data and output this in a HTML table. He has provided an answer for your request for a script, as specific as could be done given the information provided.
Edit: LOL - In the same way that you gave -
Quote:
An example of what I would like on my site is here .
- the code that grafman posted is like the code you would need to accomplish this. Being able to turn a desire to have something like something else into reality, is where the art of programming comes in. In short, either you as a programmer or a programmer you hire will be needed to do this.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Perhaps the pm system isn't working. I've seen several posts where someone didn't receive their messages. I've had one other that didn't get mine. Try again please. I don't like to post emails to the public forum. I don't want the "bots" to get to it and any other nefarious types!
UnrealEd:
I didn't use fgetcsv because "to me" its simpler to construct the html for that table right out of the array produced by file. I do that mainly because many times I have clients find that csv format conflicts with text files that have strings with commas in them. I don't have to change code other than my separator to use another delimiter. Just habits. fgetcsv would work as well!
__________________
"Things are difficult only while you don't understand them."