Interlude TOP Player ON, Level, Clan?

Discussion in 'Help' started by CDVM, Dec 9, 2010.

  1. CDVM

    CDVM New Member

    Hi people, someone know how put in the website a top to see Players on, her level and her clan? i already have one to see top pvp, pk, adena, castle etc...
     
  2. Falcon

    Falcon AdvExt64 Customers (GF/GE/HF)

    As same, as top PVP but different query
     
  3. CDVM

    CDVM New Member

    u don't know a web site for l2off that show players on, lvl & clan?
     
  4. Fr3DBr

    Fr3DBr Guest

    You just need to learn some php and sql queries bro, then you can do this stuff yourself instead of digging around trying to find a solution :)
     
  5. FidoW

    FidoW AdvExt64 Customers (IL)

    Code:
    <?
    
    include_once "config.php";
    
    // db class & connection
    $db = new db(1);
    
    // do_query return an array with the required data
    $playerlist = $db->do_query("
      SELECT TOP 10 char_name as Char,lev as Level,name as Clan,
        (CASE WHEN ((login>logout) OR (login IS NOT NULL AND logout IS NULL)) then 'On' else 'Off' end) as [On]
      FROM user_data
      LEFT JOIN pledge ON pledge.pledge_id = user_data.pledge_id
      WHERE builder = 0 AND account_id > 0
      ORDER BY exp DESC
    ");
    
    // printing array in a table
    echo "<table width='400' cellspading='0' cellspacing='0' border='1'><tr>";
    // printing field names
    foreach($playerlist[0] as $f=>$d) {
      echo "<td><b>$f</b></td>";
    }
    echo "</tr>";
    // printing field data
    foreach($playerlist as $pl) {
      echo "<tr>";
      foreach($pl as $f=>$d) echo "<td>$d</td>";
      echo "</tr>";
    }
    echo "</table>";
    
    ?>
    
     
  6. CDVM

    CDVM New Member

    Don't Work :/
     
  7. FidoW

    FidoW AdvExt64 Customers (IL)

    Of course not, you need my db class or add your own connection.
     
  8. CDVM

    CDVM New Member

    i put my own connection and nothing :S

    u can put here ur config.php? coz i did everything and don't work :S
     
  9. Zhengyi

    Zhengyi New Member

    Post yours so someone can see maybe where you went wrong or missed.
     
  10. FidoW

    FidoW AdvExt64 Customers (IL)

    Well... extracted from my db class just the needed code to make this work, so final code will be something like this:

    Code:
    <?
    
    // db config
    $dbaddress = "127.0.0.1";
    $dbuser = "dbuser";
    $dbpass = "dbpass";
    $worlddbname = "lin2world";
    // db connection
    mssql_connect($dbaddress,$dbuser,$dbpass); 
    mssql_select_db($worlddbname);
    // function to return an array with the required data
    function do_query($query) {  
      $arr = array();
      $result = @mssql_query($query);
      for ($x=0; $arr[$x] = @mssql_fetch_assoc($result); $x++);
      unset($arr[count($arr)-1]);
      return $arr;
    }
    
    $playerlist = do_query("
      SELECT TOP 10 char_name as Char,lev as Level,name as Clan,
        (CASE WHEN ((login>logout) OR (login IS NOT NULL AND logout IS NULL)) then 'On' else 'Off' end) as [On]
      FROM user_data
      LEFT JOIN pledge ON pledge.pledge_id = user_data.pledge_id
      WHERE builder = 0 AND account_id > 0
      ORDER BY exp DESC
    ");
    
    // printing array in a table
    echo "<table width='400' cellspading='0' cellspacing='0' border='1'><tr>";
    // printing field names
    foreach($playerlist[0] as $f=>$d) {
      echo "<td><b>$f</b></td>";
    }
    echo "</tr>";
    // printing field data
    foreach($playerlist as $pl) {
      echo "<tr>";
      foreach($pl as $f=>$d) echo "<td>$d</td>";
      echo "</tr>";
    }
    echo "</table>";
    
    ?>

    Now yes, it's ready to use, i was hoping maybe i can make you try to learn a bit of php.. just a bit..
     
    Last edited: Dec 13, 2010