Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    May 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to parse best of stats.ini to tables

    ]Hi guys great site you got here, im wondering if someone can give me a hand. im trying to set up stats for a game i play. i have a game that outputs stats to a file called stats.ini i want to take this data and put it in tables. i found out kinda how to do this but it takes everything! and i dont want everything i just want like the top 10 or something. here is the code im using now

    Code:
    <html>
    <body bgcolor="#000000" text="#FF8a00">
    <? 
    // file() makes an array of each line of the file 
    $players = file("/home/council/public_html/stats/stats.ini"); 
    
    echo "<table border=1 cellspacing=1 cellpadding=1>"; 
    
    // loop through each line 
    foreach($players as $each){ 
    
      // explode line into an array 
      $line = explode(",",$each); 
      echo "<tr><td>".$line[0]."</td><td>".$line[1]."</td><td>".$line[2]."</td></tr>\n"; 
    } 
    
    echo "</table>";

    and it displays this

    http://www.councilofvalhalla.com/stats/test.php

    here is the data file
    http://www.councilofvalhalla.com/stats/


    if there is anyone that could help me it would be most appreciated.thanks

  • #2
    New Coder
    Join Date
    Dec 2003
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm guessing that you have some sort of number for each player that you can decide which are the best 10 players!

    If so i would make a file with fields like: [playername];[playerscore]

    then compare the highest [playerscore] for each player (limit it to 10 using FOR loops, or others) and then display it.

  • #3
    New to the CF scene
    Join Date
    May 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well the .ini file lists all the players then it lists kills then deaths and then it averages them and lists points. i just need a way to maybe insert these fields into a database or display the top points. when u click on that link all it does is display exactly what the stats.ini looks like.

    im sorry im a noob with php so i dont know too many commands.

  • #4
    New Coder
    Join Date
    Dec 2003
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts
    can you post how an original file would look like?

  • #5
    New to the CF scene
    Join Date
    May 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    its like 2000 lines so i didnt post it here but the link is right here

    http://www.councilofvalhalla.com/stats/stats.ini

  • #6
    New to the CF scene
    Join Date
    May 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hey man i got this far

    Code:
    <?php 
    
    $line = file("C:\Inetpub\wwwroot\stats.ini"); 
    
    echo "<table> 
              <tr><td>Player Name</td> 
              <td>Kills      </td> 
              <td>Deaths     </td> 
              <td>Points     </td> 
         </tr>"; 
    
    for($i=1;$i<=10;$i++) 
    { 
    $name = $line[0+$i]; 
    $name = substr($name, 9); 
    
    $kill = $line[500+$i]; 
    $kill = substr($kill, 9); 
    
    $death = $line[1000+$i]; 
    $death = substr($death, 10); 
    
    $points = $line[1000+$i]; 
    $points = substr($points, 10); 
    
    echo "<tr><td>".$name."</td> 
                    <td>".$kill."</td> 
                    <td>".$death."</td> 
                    <td>".$points."</td> 
             </tr>"; 
    
    } 
    
    ?>
    and it displays this but the problem is it only displays the top 10 lines not the highest ranking. it does good and puts the kills,deaths,points with the name but i need it to find the highest points and just display those names. if this needs a database thats not problem i just need help getting the code. thanks guys

    Player Name Kills Deaths Points
    KrazyYak[cov] 146 163 163
    Player 0 1 1
    Alien[CoV] 15 30 30
    KrazyYak[cov²] 164 122 122
    [kod]bonebreaker[co] 17 35 35
    MiLkNcOoKiEs[cov] 133 183 183
    Dave 40 32 32
    -=BH=-][*AchiLLeS*][ 20 13 13
    xNSx_//_ForgottenOne 49 19 19
    Lord_Hollowman 1 5 5
    Last edited by firepages; 05-24-2004 at 09:10 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •