We moved our repositories to BitBucket!

If you can't login or you can't register to the forums do not rise an issue, instead please write to support (at) l2jserver.com

Check our wiki!

Report server issues here

Forum has been updated to phpBB 3.2, let's see if this fixes some minor bugs we had.

Thank you for visiting http://www.l2jserver.com/

Select A Ranking to home page

Have you created a useful tool? or Do you want to get help building one? This is the right place!
Forum rules
READ NOW: L2j Forums Rules of Conduct
Attila
Posts: 424
Joined: Mon May 05, 2014 10:15 am

Select A Ranking to home page

Post by Attila » Sun Aug 28, 2016 11:19 am

Hello Don't no if i can post it here
But i need some help with this i try to put Select A Ranking to my hopepage.
With:
TOP PVP
TOP PK
HEROES
CASTLE SIEGE
RAID BOSSES
TOP PvP and TOP pk and CASTLE SIEGE works all fine.
Only i can't get HEROES and RAID BOSSES to work
Someone can tell me what i need to change in to script to let it works please
Its is for: High five -Master Branch
thanks

Code: Select all

<section class="content-wrap">

<div class="title-page">SELECT A RANKING</div>

<style type="text/css">
table td { width:340px; height:40px; background:#FFF; border:2px solid #cbcbcb; font-family:Cambria, "Hoefler Text", "Liberation Serif", Times, "Times New Roman", serif; text-align:center; font-size:18px; color:#545454; margin-top:15px; border-radius:5px;
} 


</style>

<form method="post">

<select class="input-default-pages" style="width:691px;" name="rankselect">
<option value="0"> SELECT A RANKING... </option>
<option value="1"> TOP PVP </option>
<option value="2"> TOP PK </option>
<option value="3"> HEROES </option>
<option value="4"> CASTLE SIEGE </option>
<option value="5"> RAID BOSSES </option>

</select>
<input type="submit" name="search" value="SEARCH" class="btn-default-pages" style="width:691px;" />

</form>




    

<?php 

if(isset($_POST['search'])) { 

$rankselect = $_POST['rankselect'];
$i = 1;
if($rankselect == 1) {
	?>
    
    <table width="691" cellpadding="10" cellspacing="10" border="0">
  <tbody> 
    <tr>
      <td>Pos.</td>
      <td>Nickname</td>
      <td>Pvpkills</td>
    </tr>
    <?php
$queryselectpvp = 'SELECT * FROM characters ORDER BY pkkills DESC LIMIT 25 '; 
$querypvp = $db -> prepare($queryselectpvp); 
$querypvp -> execute(); 
while ($respvp = $querypvp -> fetch (PDO::FETCH_OBJ)) {
	?>
	   <tr>
      <td><?php echo $i++ ?>º</td>
      <td><?php echo $respvp-> char_name; ?></td>
      <td><?php echo $respvp-> pvpkills; ?></td>
    </tr>
    <?php
}
}
}

?>

  </tbody>
</table>

<?php 

if(isset($_POST['search'])) { 
$rankselect = $_POST['rankselect'];
$i = 1;
if($rankselect == 2) {
	?>
    <table width="691" cellpadding="10" cellspacing="10" border="0">
  <tbody> 
    <tr>
      <td>Pos.</td>
      <td>Nickname</td>
      <td>Pk kills</td>
    </tr>
    <?php
$queryselectpk = 'SELECT * FROM characters ORDER BY pkkills DESC LIMIT 25 '; 
$querypk = $db -> prepare($queryselectpk); 
$querypk -> execute(); 
while ($respk = $querypk -> fetch (PDO::FETCH_OBJ)) {
	?>
	   <tr>
      <td><?php echo $i++ ?>º</td>
      <td><?php echo $respk-> char_name; ?></td>
      <td><?php echo $respk-> pvpkills; ?></td>
    </tr>
    <?php
}
}
}

?>

  </tbody>
</table>

<?php 

if(isset($_POST['search'])) { 
$rankselect = $_POST['rankselect'];
$i = 1;
if($rankselect == 3) {
	?>
    <table width="691" cellpadding="10" cellspacing="10" border="0">
  <tbody> 
    <tr>
      <td>Nickname</td>
      <td>Class</td>
      <td>Count</td>
    </tr>
    <?php
$queryselectheroes = 'SELECT h.*,c.ClassId, c.ClassName FROM heroes h LEFT JOIN char_templates c ON h.class_id = c.classId ORDER BY c.ClassName ASC '; 

$queryheroes = $db -> prepare($queryselectheroes); 
$queryheroes -> execute(); 
while ($resheroes = $queryheroes -> fetch (PDO::FETCH_OBJ)) {
	?>
	   <tr>
      <td><?php echo $resheroes-> char_name; ?></td>
      <td><?php echo $resheroes-> class_id; ?></td>
      <td><?php echo $resheroes-> count; ?></td>
    </tr>
    <?php
}
}
}

?>

  </tbody>
</table>


<?php 

if(isset($_POST['search'])) { 
$rankselect = $_POST['rankselect'];
$i = 1;
if($rankselect == 4) {
	?>
    <table width="691" cellpadding="10" cellspacing="10" border="0">
  <tbody> 
    <tr>
      <td>Castle Name: </td>
      <td>Tax:</td>
      <td>Next Siege:</td>
    </tr>
    <?php
	

$queryselectcastle = 'SELECT * FROM castle ORDER BY name ASC'; 

$querycastle = $db -> prepare($queryselectcastle); 
$querycastle -> execute(); 
while ($rescastle = $querycastle -> fetch (PDO::FETCH_OBJ)) {
	$SiegeDate=date('j/m/Y H\:i',$rescastle-> siegeDate/1000);
	?>
	   <tr>
      <td><?php echo $rescastle-> name; ?></td>
      <td><?php echo $rescastle-> taxPercent; ?>%</td>
      <td><?php echo $SiegeDate; ?></td>
    </tr>
    <?php
}
}
}

?>

  </tbody>
</table>


<?php 

if(isset($_POST['search'])) { 
$rankselect = $_POST['rankselect'];
$i = 1;
if($rankselect == 5) {
	?>
    
        <div class="title-page" style="margin-bottom:15px;">BIG BOSSES</div>
    <table width="691" cellpadding="10" cellspacing="10" border="0">
  <tbody> 
    <tr>
      <td>Name</td>
        <td>Level</td>
      <td>Status</td>
    </tr>
    <?php
	try { 
$queryselectbig = "SELECT b.*,n.id, n.name,n.level FROM grandboss_data b LEFT JOIN npc n ON b.boss_id = n.id  ORDER BY n.name ASC"; 

$querybossesbig = $db -> prepare($queryselectbig); 
$querybossesbig -> execute(); 
while ($resbossesbig = $querybossesbig -> fetch (PDO::FETCH_OBJ)) {
	$respawnbig = $resbossesbig->respawn_time; 
	$convertdatebig = date('d/m/Y H:i:s',($respawn->respawn_time / 1000));
	?>
	   <tr>
      <td><?php echo $resbossesbig-> name; ?></td>
      <td><?php echo $resbossesbig-> level; ?></td>
      <td>
	  <?php if($resbossesbig->respawn_time == 0){
echo "<div style='color:green' class='glyphicon glyphicon-ok'></div>";
} else { echo $convertdatebig; }
 ?>
       </td>
    </tr>
    <?php

}
} catch (PDOException $e) {
	echo $e->getMessage();
}
?>
  </tbody>
</table>


    <div class="title-page" style="margin-bottom:15px; clear:both; margin-top:15px;">RAID BOSSES</div>
    <table width="691" cellpadding="10" cellspacing="10" border="0">
  <tbody> 
    <tr>
      <td>Name</td>
        <td>Level</td>
      <td>Status</td>
    </tr>
    <?php
$queryselectbosses = 'SELECT b.*,n.id, n.name,n.level FROM raidboss_spawnlist b LEFT JOIN npc n ON b.boss_id = n.id ORDER BY n.name ASC '; 

$querybosses = $db -> prepare($queryselectbosses); 
$querybosses -> execute(); 
while ($resbosses = $querybosses -> fetch (PDO::FETCH_OBJ)) {
	$respawn = $resbosses->respawn_time; 
	$convertdate = date('d/m/Y H:i:s',($respawn->respawn_time / 1000));
	?>
	   <tr>
      <td><?php echo $resbosses-> name; ?></td>
      <td><?php echo $resbosses-> level; ?></td>
      <td>
	  <?php if($resbosses->respawn_time == 0){
echo "<div style='color:green' class='glyphicon glyphicon-ok'></div>";
} else { echo $convertdate; }
 ?>
       </td>
    </tr>
    <?php
}
}
}

?>

  </tbody>
</table>

</section>

Attila
Posts: 424
Joined: Mon May 05, 2014 10:15 am

Re: Select A Ranking to home page

Post by Attila » Wed Aug 31, 2016 4:53 pm

Someone to help me whit this please

dasoldier
Posts: 73
Joined: Wed May 31, 2006 6:26 pm
Location: Holland
Contact:

Re: Select A Ranking to home page

Post by dasoldier » Wed Aug 31, 2016 6:23 pm

Hey,

Heroes:
Try to run this as query in your database.

Code: Select all

SELECT h.*,c.ClassId, c.ClassName FROM heroes h LEFT JOIN char_templates c ON h.class_id = c.classId ORDER BY c.ClassName ASC
And see what error pops up.
( high chance that char_tamplates table does not exist anymore.)

Raid bosses
Try to run this as query in your database.

Code: Select all

SELECT b.*,n.id, n.name,n.level FROM raidboss_spawnlist b LEFT JOIN npc n ON b.boss_id = n.id ORDER BY n.name ASC
And see what error pops up.
( high chance that npc table does not exist anymore. it is changed to xml format)

Good luck.

User avatar
Sacrifice
Advanced User
Advanced User
Posts: 974
Joined: Thu Aug 14, 2014 6:31 am
Location: Spain

Re: Select A Ranking to home page

Post by Sacrifice » Wed Aug 31, 2016 7:26 pm

:lol: you're :evil:

Attila
Posts: 424
Joined: Mon May 05, 2014 10:15 am

Re: Select A Ranking to home page

Post by Attila » Thu Sep 01, 2016 3:41 pm

Table 'l2dw.char_templates' doesn't exist
Table 'l2dw.npc' doesn't exist

Yes you are right table does not exist anymore.
But what do i need to change now to get it work.


dasoldier wrote:Hey,

Heroes:
Try to run this as query in your database.

Code: Select all

SELECT h.*,c.ClassId, c.ClassName FROM heroes h LEFT JOIN char_templates c ON h.class_id = c.classId ORDER BY c.ClassName ASC
And see what error pops up.
( high chance that char_tamplates table does not exist anymore.)

Raid bosses
Try to run this as query in your database.

Code: Select all

SELECT b.*,n.id, n.name,n.level FROM raidboss_spawnlist b LEFT JOIN npc n ON b.boss_id = n.id ORDER BY n.name ASC
And see what error pops up.
( high chance that npc table does not exist anymore. it is changed to xml format)

Good luck.

User avatar
Sacrifice
Advanced User
Advanced User
Posts: 974
Joined: Thu Aug 14, 2014 6:31 am
Location: Spain

Re: Select A Ranking to home page

Post by Sacrifice » Thu Sep 01, 2016 5:01 pm

Attila wrote:Table 'l2dw.char_templates' doesn't exist
Table 'l2dw.npc' doesn't exist

Yes you are right table does not exist anymore.
But what do i need to change now to get it work.


dasoldier wrote:Hey,

Heroes:
Try to run this as query in your database.

Code: Select all

SELECT h.*,c.ClassId, c.ClassName FROM heroes h LEFT JOIN char_templates c ON h.class_id = c.classId ORDER BY c.ClassName ASC
And see what error pops up.
( high chance that char_tamplates table does not exist anymore.)

Raid bosses
Try to run this as query in your database.

Code: Select all

SELECT b.*,n.id, n.name,n.level FROM raidboss_spawnlist b LEFT JOIN npc n ON b.boss_id = n.id ORDER BY n.name ASC
And see what error pops up.
( high chance that npc table does not exist anymore. it is changed to xml format)

Good luck.
Cant be possible, sorry.

Attila
Posts: 424
Joined: Mon May 05, 2014 10:15 am

Re: Select A Ranking to home page

Post by Attila » Thu Sep 01, 2016 5:35 pm

Oke thanks for the help :+1:

dasoldier
Posts: 73
Joined: Wed May 31, 2006 6:26 pm
Location: Holland
Contact:

Re: Select A Ranking to home page

Post by dasoldier » Sun Sep 04, 2016 5:30 pm

I have fixed the hero part for you.
It is not really tested but the results looked oke.

Code: Select all

<!DOCTYPE html>
<html>
<head>
</head>
<?php 

		// Server Database Config
		$db_host		= '1.1.1.1';
		$db_user		= 'user';
		$db_pass		= 'pass';
		$db_database	= 'l2jgs';

		try
		{
			// Try to make connection.
			$connection = new PDO("mysql:host=$db_host;dbname=$db_database;charset=utf8", $db_user, $db_pass);
			$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$class_name = array(
					'88' => "Duelist",
					'89' => "Dread Nought",
					'90' => "Phoenix Knight",
					'91' => "Hell Knight",
					'92' => "Sagittarius",
					'93' => "Adventurer",
					'94' => "Archmage",
					'95' => "Soul Taker",
					'96' => "Arcane Lord",
					'97' => "Cardinal",
					'98' => "Hierophant",
					'99' => "Evas Templar",
					'100' => "Sword Muse",
					'101' => "Wind Rider",
					'102' => "Moonlight Sentinel",
					'103' => "Mystic Muse",
					'104' => "Elemental Master",
					'105' => "Evas Saint",
					'106' => "Shillien Templar",
					'107' => "Spectral Dancer",
					'108' => "Ghost Hunter",
					'109' => "Ghost Sentinel",
					'110' => "storm Screamer",
					'111' => "Spectral Master",
					'112' => "Shillien Saint",
					'113' => "Titan",
					'114' => "Grand Khauatari",
					'115' => "Dominator",
					'116' => "Doomcryer",
					'117' => "Fortune Seeker",
					'118' => "Maestro",
				);

				// Get data from heroes and character table
				$character_row = $connection->prepare('SELECT heroes.charId, heroes.class_id, characters.char_name FROM heroes , characters WHERE heroes.charId =  characters.charId ');
				
				echo '<b>Hero list</b><br>';
				
				echo '<table>';
				if ($character_row->execute())
					{
					    while ($row = $character_row->fetch(PDO::FETCH_ASSOC))
							{
								echo '<tr><td>', $row['char_name'],'</td><td>', $class_name[$row['class_id']], '</td></tr>' ;
							}
					}
				echo '</table>';
		}
		catch(PDOException $e)
		{
			echo 'ERROR: ' . $e->getMessage();
		}
				$connection = null;
?>
</html>
When i got some time i will try to create a code for raidbosses.

Edit: Ohh yea the kamael classes are missing you can add them to the class_name array.

:wave:
Last edited by dasoldier on Tue Sep 06, 2016 6:35 pm, edited 1 time in total.

Attila
Posts: 424
Joined: Mon May 05, 2014 10:15 am

Re: Select A Ranking to home page

Post by Attila » Sun Sep 04, 2016 5:47 pm

Thanks man :+1:
but how do i put this to the script I use above ?
dasoldier wrote:I have fixed the hero part for you.
It is not really tested but the results looked oke.

Code: Select all

<!DOCTYPE html>
<html>
<head>
</head>
<?php 

		// Server Database Config
		$db_host		= '1.1.1.1';
		$db_user		= 'user';
		$db_pass		= 'pass';
		$db_database	= 'l2jgs';

		// Try to make connection.
		$connection = new PDO("mysql:host=$db_host;dbname=$db_database;charset=utf8", $db_user, $db_pass);
		$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$class_name = array(
					'88' => "Duelist",
					'89' => "Dread Nought",
					'90' => "Phoenix Knight",
					'91' => "Hell Knight",
					'92' => "Sagittarius",
					'93' => "Adventurer",
					'94' => "Archmage",
					'95' => "Soul Taker",
					'96' => "Arcane Lord",
					'97' => "Cardinal",
					'98' => "Hierophant",
					'99' => "Evas Templar",
					'100' => "Sword Muse",
					'101' => "Wind Rider",
					'102' => "Moonlight Sentinel",
					'103' => "Mystic Muse",
					'104' => "Elemental Master",
					'105' => "Evas Saint",
					'106' => "Shillien Templar",
					'107' => "Spectral Dancer",
					'108' => "Ghost Hunter",
					'109' => "Ghost Sentinel",
					'110' => "storm Screamer",
					'111' => "Spectral Master",
					'112' => "Shillien Saint",
					'113' => "Titan",
					'114' => "Grand Khauatari",
					'115' => "Dominator",
					'116' => "Doomcryer",
					'117' => "Fortune Seeker",
					'118' => "Maestro",
				);

				// Get data from heroes and character table
				$character_row = $connection->prepare('SELECT heroes.charId, heroes.class_id, characters.char_name FROM heroes , characters WHERE heroes.charId =  characters.charId ');
				
				echo '<b>Hero list</b><br>';
				
				echo '<table>';
				if ($character_row->execute())
					{
					    while ($row = $character_row->fetch(PDO::FETCH_ASSOC))
							{
								echo '<tr><td>', $row['char_name'],'</td><td>', $class_name[$row['class_id']], '</td></tr>' ;
							}
					}
				echo '</table>';
				$connection = null;
?>
</html>
When i got some time i will try to create a code for raidbosses.

Edit: Ohh yea the kamael classes are missing you can add them to the class_name array.

:wave:

User avatar
Sacrifice
Advanced User
Advanced User
Posts: 974
Joined: Thu Aug 14, 2014 6:31 am
Location: Spain

Re: Select A Ranking to home page

Post by Sacrifice » Sun Sep 04, 2016 5:54 pm

Code: Select all

<?php 

      // Server Database Config
      $db_host      = '1.1.1.1';
      $db_user      = 'user';
      $db_pass      = 'pass';
      $db_database   = 'l2jgs';

      // Try to make connection.
      $connection = new PDO("mysql:host=$db_host;dbname=$db_database;charset=utf8", $db_user, $db_pass);
      $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$class_name = array(
               '88' => "Duelist",
               '89' => "Dread Nought",
               '90' => "Phoenix Knight",
               '91' => "Hell Knight",
               '92' => "Sagittarius",
               '93' => "Adventurer",
               '94' => "Archmage",
               '95' => "Soul Taker",
               '96' => "Arcane Lord",
               '97' => "Cardinal",
               '98' => "Hierophant",
               '99' => "Evas Templar",
               '100' => "Sword Muse",
               '101' => "Wind Rider",
               '102' => "Moonlight Sentinel",
               '103' => "Mystic Muse",
               '104' => "Elemental Master",
               '105' => "Evas Saint",
               '106' => "Shillien Templar",
               '107' => "Spectral Dancer",
               '108' => "Ghost Hunter",
               '109' => "Ghost Sentinel",
               '110' => "storm Screamer",
               '111' => "Spectral Master",
               '112' => "Shillien Saint",
               '113' => "Titan",
               '114' => "Grand Khauatari",
               '115' => "Dominator",
               '116' => "Doomcryer",
               '117' => "Fortune Seeker",
               '118' => "Maestro",
            );

            // Get data from heroes and character table
            $character_row = $connection->prepare('SELECT heroes.charId, heroes.class_id, characters.char_name FROM heroes , characters WHERE heroes.charId =  characters.charId ');
            
            echo '<b>Hero list</b><br>';
            
            echo '<table>';
            if ($character_row->execute())
               {
                   while ($row = $character_row->fetch(PDO::FETCH_ASSOC))
                     {
                        echo '<tr><td>', $row['char_name'],'</td><td>', $class_name[$row['class_id']], '</td></tr>' ;
                     }
               }
            echo '</table>';
            $connection = null;
?>
Do a new file like... scriptname.php and paste content inside new file. Fill first lines with your server info and can include where you want...

Anyway... I dont recommend to use this type of scrips in websites... ppl can exploit concurrent connections and stop your database server.

dasoldier
Posts: 73
Joined: Wed May 31, 2006 6:26 pm
Location: Holland
Contact:

Re: Select A Ranking to home page

Post by dasoldier » Sun Sep 04, 2016 6:19 pm

I know it is a simple example how to get the correct data from the database.

Attila
Posts: 424
Joined: Mon May 05, 2014 10:15 am

Re: Select A Ranking to home page

Post by Attila » Mon Sep 05, 2016 7:41 pm

Thanks man it works :+1:
If you can make also 1 for Next Siege and a code for raidbosses
i going to love you :clap:
dasoldier wrote:I know it is a simple example how to get the correct data from the database.

dasoldier
Posts: 73
Joined: Wed May 31, 2006 6:26 pm
Location: Holland
Contact:

Re: Select A Ranking to home page

Post by dasoldier » Tue Sep 06, 2016 6:13 pm

Hey,

Yea i will try to code it for you when i have some time for it.

Castle sieges was working right ?

Edit: i have changed some code for you on the example.( added a try and catch block)
If your server is offline and run the hero script people can see your db username and password and you dont want that.

Greetings,
Dasoldier

Attila
Posts: 424
Joined: Mon May 05, 2014 10:15 am

Re: Select A Ranking to home page

Post by Attila » Wed Sep 07, 2016 12:52 pm

dasoldier wrote:Hey,

Yea i will try to code it for you when i have some time for it.

Castle sieges was working right ?

Edit: i have changed some code for you on the example.( added a try and catch block)
If your server is offline and run the hero script people can see your db username and password and you dont want that.

Greetings,
Dasoldier
Thanks works good :+1:

Attila
Posts: 424
Joined: Mon May 05, 2014 10:15 am

Re: Select A Ranking to home page

Post by Attila » Fri Sep 09, 2016 12:49 pm

yes
Castle sieges was working .
only i need it like you made it for Hero script
Attila wrote:
dasoldier wrote:Hey,

Yea i will try to code it for you when i have some time for it.

Castle sieges was working right ?

Edit: i have changed some code for you on the example.( added a try and catch block)
If your server is offline and run the hero script people can see your db username and password and you dont want that.

Greetings,
Dasoldier
Thanks works good :+1:

Post Reply