Jump to content

[Guide] How to Write PHP Script


EdenEternal

Recommended Posts

Hello Ladies i want to share guide about how to write php script.it's very easy. so let's start. say for example we need top pvp kills script.

first create config.php and write there this:

 

<?php
$L2JBS_config["mysql_host"]="localhost";	// MySQL Host 	["localhost"]
$L2JBS_config["mysql_port"]="3306";		// MySQL Port			["3306"]
$L2JBS_config["mysql_db"]="l2jdb";		// MySQL Database	["l2jdb"]
$L2JBS_config["mysql_login"]="root";		// MySQL User			["root"]	
$L2JBS_config["mysql_password"]="root";	// MySQL Password			["root"]
include("_config_procs.php");
error_reporting(0);
?>

 

now create _config_procs.php

 

<?php
  $link = mysql_connect($L2JBS_config['mysql_host'].":".$L2JBS_config['mysql_port'], $L2JBS_config['mysql_login'], $L2JBS_config['mysql_password']);
  if (!$link)
die("Couldn't connect to MySQL");
  @mysql_select_db($L2JBS_config['mysql_db'], $link);
error_reporting(0);

?>

 

now create toppvp.php and write there this:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>TOP PvP Script By Leki</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style type="text/css">

<!--

body,td,th {

color: #CCCCCC;

font-family: Verdana, Arial, Helvetica, sans-serif;

font-size: 12px;

}

body {

background-color: #000000;

}

-->

</style>

</head>

<body>

<table style="border: 1px solid; border-color: #444444; background-color:#222222;" align="center" width="100%">

  <tr>

    <th class='Stil7' colspan="5" align="center" width="100%">Top 100 PvP</th>

  </tr>

  <tr>

    <th width="1%" style="border: 1px solid; border-color: #444444; background-color:#222222;">ID</th>

    <th width="10%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> Character </th>

    <th width="2%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> Level </th>

    <th width="6%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> PvP </th>

    <th width="6%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> Status </th>

  </tr>

 

  <?php

require("Config.php");

$activity = mysql_query("MySQL Query");

$i = 1;

 

while($row = mysql_fetch_array($activity))

 

{

if (!($i%2)) echo "<tr bgcolor='#000000' align='center'>";

else

echo "<tr bgcolor='#161616' align='center'>";

echo "<td>"."<center>".$i."</center>"."</td>";

echo "<td>"."<center>".$row['char_name']."</center>"."</td>";

echo "<td>"."<center>".$row['level']."</center>"."</td>";

echo "<td>"."<center>".$row['pvpkills']."</center>"."</td>";

echo "<td>"."<center>".$row['online']."</center>"."</td>";

$i++;

}

?>

</table>

</body>

</html>

 

now we need MySQL query. so open Navicat. go to your database and then open characters table.now click File -> Query Table. Then Query Builder.now we need to select fields. we need 4 field. character name,character object id, character pvpkills , characters level and of course character online status.

So for my database(La2Base Interlude) i have this fields: obj_id,char_name,level,pvpkills,online.

 

when you select your fields, again click on Query Editor. you see your sql script

i have this

 

SELECT

characters.obj_Id,

characters.char_name,

characters.level,

characters.pvpkills,

characters.online

FROM characters

 

now we need to specify now many player must be in top script and how to order.. so add this to your sql script

 

ORDER BY characters.pvpkills DESC LIMIT 10

 

so we have

 

SELECT

characters.obj_Id,

characters.char_name,

characters.level,

characters.pvpkills,

characters.online

FROM characters

ORDER BY characters.pvpkills DESC LIMIT 10

 

so copy and paste in our php script this sql query

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>TOP PvP Script By Leki</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style type="text/css">

<!--

body,td,th {

color: #CCCCCC;

font-family: Verdana, Arial, Helvetica, sans-serif;

font-size: 12px;

}

body {

background-color: #000000;

}

-->

</style>

</head>

<body>

<table style="border: 1px solid; border-color: #444444; background-color:#222222;" align="center" width="100%">

  <tr>

    <th class='Stil7' colspan="5" align="center" width="100%">Top 100 PvP</th>

  </tr>

  <tr>

    <th width="1%" style="border: 1px solid; border-color: #444444; background-color:#222222;">ID</th>

    <th width="10%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> Character </th>

    <th width="2%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> Level </th>

    <th width="6%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> PvP </th>

    <th width="6%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> Status </th>

  </tr>

 

  <?php

require("Config.php");

$activity = mysql_query("SELECT

characters.obj_Id,

characters.char_name,

characters.level,

characters.pvpkills,

characters.online

FROM characters

ORDER BY characters.pvpkills DESC LIMIT 10");

$i = 1;

 

while($row = mysql_fetch_array($activity))

 

{

if (!($i%2)) echo "<tr bgcolor='#000000' align='center'>";

else

echo "<tr bgcolor='#161616' align='center'>";

echo "<td>"."<center>".$i."</center>"."</td>";

echo "<td>"."<center>".$row['char_name']."</center>"."</td>";

echo "<td>"."<center>".$row['level']."</center>"."</td>";

echo "<td>"."<center>".$row['pvpkills']."</center>"."</td>";

echo "<td>"."<center>".$row['online']."</center>"."</td>";

$i++;

}

?>

</table>

</body>

</html>

 

now we need to discuss online and offline characters yes?

so replace this

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>TOP PvP Script By Leki</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style type="text/css">

<!--

body,td,th {

color: #CCCCCC;

font-family: Verdana, Arial, Helvetica, sans-serif;

font-size: 12px;

}

body {

background-color: #000000;

}

-->

</style>

</head>

<body>

<table style="border: 1px solid; border-color: #444444; background-color:#222222;" align="center" width="100%">

  <tr>

    <th class='Stil7' colspan="5" align="center" width="100%">Top 100 PvP</th>

  </tr>

  <tr>

    <th width="1%" style="border: 1px solid; border-color: #444444; background-color:#222222;">ID</th>

    <th width="10%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> Character </th>

    <th width="2%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> Level </th>

    <th width="6%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> PvP </th>

    <th width="6%" style="border: 1px solid; border-color: #444444; background-color:#222222;"> Status </th>

  </tr>

 

  <?php

require("Config.php");

$activity = mysql_query("SELECT

characters.obj_Id,

characters.char_name,

characters.level,

characters.pvpkills,

characters.online

FROM characters

ORDER BY characters.pvpkills DESC LIMIT 10");

$i = 1;

 

while($row = mysql_fetch_array($activity))

 

{

if (!($i%2)) echo "<tr bgcolor='#000000' align='center'>";

else

echo "<tr bgcolor='#161616' align='center'>";

echo "<td>"."<center>".$i."</center>"."</td>";

echo "<td>"."<center>".$row['char_name']."</center>"."</td>";

echo "<td>"."<center>".$row['level']."</center>"."</td>";

echo "<td>"."<center>".$row['pvpkills']."</center>"."</td>";

if ($row['online'] == 1)

echo "<td>"."<center>Online</center>"."</td>";

else

echo "<td>"."<center>Offline</center>"."</td>";

$i++;

}

?>

</table>

</body>

</html>

 

So it's look like this:

 

37668565.png

 

Finish. I think i deserve karma  :P

Link to comment
Share on other sites

Man i think is wrong way to learn How to Write PHP Script.

 

If someone want to write php script let go to php.net to learn the basics for php language and after let read a tutorial for sql language and finaly lets write a php script.

 

This is my opinion...

Link to comment
Share on other sites

  • 2 months later...

damn i know 000000 about this,whaen you say create config.php file,you mean how?Say i create a php file,i add the code in there?What i add to website...I dont undersatnd a thing,if anyone with video guide or else pls post..

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • ??? error   https://ibb.co/Srn4LsX No support  :S   No support : S ? :S
    • I also think this feature would bring more harm than good... another example is a dwarf rushing against your mobs so he takes priority, then he plays fake death and proceeds to grief the shit out of you. A minimum damage threshold is necessary, which would basically converge to what is the default feature (i.e. biggest damage dealer)
    • I bought the premium to watch the video and it's private. 😢
    • For some Majestic reason OP can't edit their topics anymore?    Let me update the potential offers, I got up to 2 spots to fill.   CONTACT TELEGRAM ONLY: https://t.me/asupport_g1     A credible team that SGuard represents is looking for java developers.    These positions is full time only i.e. your time is mostly dedicated within the team and team tasks, side gigs are fine, as long as you are able to combine your gig and main.  All necessary tools are provided.  The team is consistent with > 10 team members and the team is looking to expand to meet various goals. A decent Lineage 2 Essense OR Main (GOD) knowledge is needed.  Experience with l2r/l2p/l2s. mobius is fine too for referrence only. The team is friendly and goal oriented, very active and resourceful.   Requirements are standard, java knowledge is optional.  Multi language is a plus but not necessary (English/Russian), any is accepted.   Terms and conditions including compensation are reasonable and considered to be up for the industry standards. Details are negotiable with suitable candidates.   You will need to have a headset and a mic just for the initial processing, there're no team meetings or conferences after that. There's a small 30min interview process to demonstrate knowledge and just to meet each other.   The team has decided it is in their best interest to not publish their information at this time. Details will be available only for suitable candidates.   CONTACT TELEGRAM ONLY: https://t.me/asupport_g1
    • Thanks for the detailed info. I also have some ideas in mind but the execution may be hard. Thanks again!
  • Topics

×
×
  • Create New...