70470 Posts in 6879 Topics - by 687 Members - Latest Member: Laricwashere

Author Topic: Displaying Statistics In PhP  (Read 951 times)

Offline .:F3ar0n:.

  • Staff
  • Godlike Gamer
  • *
  • Posts: 2093
  • Karma: 0
  • https://www.youtube.com/watch?v=uIOqrfeC1Q4#t=20
  • Steam ID: H4xz0rsaurusRX
  • XBox Gamer Tag: F3ar0n8
Displaying Statistics In PhP
« on: September 04, 2008, 12:06:57 PM »
Ok, so I have this tron server which automatically creates several txt files displaying statistics of the game. It'll display the ladder, matches won, rounds won, who's online and so on.

So I want to create a page to display these stats to the user. I originally was going to display them using an iframe which would separate the page into 4 frames...top being who's online, and from left to right the ladder, match won and rounds won

I do a php include "rounds.txt" and it outputs the txt file to the page but there is no organization

http://fight-clan.wwwd.name/test.php

So my question would be...how could I import a txt file then organize it to display everything in a clean list. Do I have to import the txt file into a database and then recall the database as a organized list (I've done this before with ASP but never in PHP)

I assumed this would be what I would have to do therefor I have the tron server automatically ftp'ing the stats data to both my personal server (which has php and mysql installed) and to server who is hosting it

http://fight-clan.wwwd.name/index.php?topic=46.msg195#new

If i have to upload the file into a database in order to recall it..How would I go about having the file automatically update to the database every 10 min or w/e? Any advice or linkage on this would be helpful. Until then i'll continue my search on google for the answer

**prays someone here has advance web dev skillz

Offline _!Rathe!_

  • Master Sergeant Shooter Sergeant Person
  • Godlike Gamer
  • *
  • Posts: 2296
  • Karma: 0
  • XFire: rathewin2k
Re: Displaying Statistics In PhP
« Reply #1 on: September 04, 2008, 01:50:34 PM »
The reason the text is in disarray is because all you are doing is displaying the text file as it is being written by the server.  You can open the file with the FOpen function. You can then read it line by line and format it how you want.  Loading the file on a periodic basis would require a cron job but putting the output into the mysql database. 
Never, but never question the engineers judgement.

Offline The Shoctor

  • Administrator
  • Godlike Gamer
  • *
  • Posts: 5803
  • Karma: 17
  • Steam ID: shadohawk@shadoworks.net
  • XBox Gamer Tag: TheShoctor
  • XFire: shadoworks
Re: Displaying Statistics In PhP
« Reply #2 on: September 04, 2008, 02:50:28 PM »
I prefer file_get_contents.
http://us.php.net/manual/en/function.file-get-contents.php
Then you have it in one variable. No need to enter it into a database. And you can parse as you like. I think both functions are good, but the one I am talking about can pull from other sites and the file doesn't need to be on the same server as the webserver.

Support LAN Play!
ლ(ಠ益ಠლ) "I have more than 20 friends EA!" --FITES.NET
(╯°□°)╯︵ ┻━┻
"Close enough." --UGC League