php scripts similar to lineagedb

From Lineage Retribution

Viewed 118 times, With a total of 16 Posts

Wiki Edits: 0
Threads 2
Posts 6

I have started writing some php scripts that, when completed, can be copied to the webserver of any l1j private server and presents information from the server database (such as drops, item and monster information), npc locations, etc).

These are available for review at the following locations:
http://pano.doorsphotography.com/lin/item.php
http://pano.doorsphotography.com/lin/location.php
http://pano.doorsphotography.com/lin/npc.php

Please let me know if anybody is interested in using these, otherwise I will not develop these any further.


Wiki Edits: 3
Threads 15
Posts 106

That php code is long, There are other way's to do the same thing. o_o Without showing everything.

These is a php that is smaller then your and more well displayed, I'm not saying you did a bad job, You did great work.. =) But if you want to display something try something like this

<?php
$db = mysql_connect("localhost","username","password");
mysql_select_db("newdb", $db);
$query = mysql_query("SELECT * FROM links");
echo '

';
while ($r = mysql_fetch_assoc($query)) {
echo '';
}
echo '
', implode('',$r), '
';
?>



Your should be about this long.



<?PHP

  1. Param 1 : MySQL Host Name
  2. Param 2 : MySQL Username
  3. Param 3 : MySQL Password
  4. Param 4 : MySQL Database
  5. Param 5 : SQL Statement (SELECT)

show_table("66.176.96.57","root","","newdb","SELECT * FROM armor");

function show_table($hostName,$userName,$passWord,$dataBase,$sqlQuery)
{

  1. Connect to MySQL

$conn=mysql_connect($hostName,$userName,$passWord);
  1. Select Database

mysql_select_db($dataBase,$conn);
  1. Validate SQL Statement

$array=explode(" ORDER",$sqlQuery);
$sqlQuery=$array[0];
if(!strstr($sqlQuery,"SELECT"))
die("Invalid Query : SQL statement should be a SELECT statement.");
  1. ORDER records by requested column

if($_GET['order'])
$sqlQuery=$sqlQuery." ORDER BY ".$_GET['order'];
  1. Execute SQL query

$result=mysql_query($sqlQuery) or die("Invalid Query : ".mysql_error());
$row=mysql_fetch_array($result);
  1. Check whether NULL records found

if(!mysql_num_rows($result))
die("No records found.");
echo "";
  1. Make the row for table column names

while (list($key, $value) = each($row))
{
$i++;
if(!($i%2))
echo "";
for($i=0;$i<count($rec);$i++)
{
if($rec[$i])
echo "

<a href='?order=$key'>$key</a></td>";
}
echo "</tr>";
$result=mysql_query($sqlQuery);
// Make rows for records
while($rec=mysql_fetch_array($result))
{
echo "
$rec[$i]</td>";
}
echo "</tr>";
}
echo "</table>";
}
?>

I move in silence, Speak with violence, Think with science, Live free and walk with lion.


Wiki Edits: 3
Threads 15
Posts 106

The code is all mess up now lol.. =D Sorry

I move in silence, Speak with violence, Think with science, Live free and walk with lion.


Wiki Edits: 0
Threads 2
Posts 6

Yeah but in order to display all that information it takes numbers from one table and does a lookup using another table to find that information and print something that means something to a person.


Wiki Edits: 3
Threads 15
Posts 106

Yea, So you make links.. =) Its an easy written code. And displays the information much better.

I move in silence, Speak with violence, Think with science, Live free and walk with lion.


Wiki Edits: 0
Threads 2
Posts 6

Well, I suppose I could do it that way, but I really wanted to be able to sort the lists by various criteria and other nifty things. The names listed in the database tables don't really make for a nice readable output IMHO.
Most of the code goes into setting flags for sorting the results or printing the output table. And it is organized in such a manner to allow customization by each individual server that uses the scripts.

Or course, when showing item drops, this method doesn't work. I'm just trying to get feedback to see if this is something that various l1j servers would want to provide.


Wiki Edits: 111
Threads 29
Posts 624

I would say that this would be something of great benefit to the private server community. Allowing players the capability to browse the listings of what the server has to offer helps enhance the gameplay experience.

- Zylia, Research and Development


Wiki Edits: 3
Threads 15
Posts 106

I have a db display code I use, I'll post it up when I get a good chance.

I move in silence, Speak with violence, Think with science, Live free and walk with lion.


Wiki Edits: 0
Threads 9
Posts 27

that would be awesome. especially if yours grabs images too lol


Wiki Edits: 111
Threads 29
Posts 624

Adding images for inventory items, ground items and sprites has to be generated manually, and is quite a bit of a laboring task. I'm in the process of a full sprite dump. I'll be migrating these into animated gif's eventually, but again.. it's very labor intensive.

- Zylia, Research and Development


Wiki Edits: 3
Threads 15
Posts 106

$result1 = mysql_query ( "SELECT

   weapon.name, weapon.invgfx
   FROM
   weapon
   WHERE
   type = 'dagger'");


while ($row = mysql_fetch_assoc ( $result1 )) {
   echo '<img src="images/gfx/' . $row["gfxid"] . '.png" />';
   echo $row["name"] . '
'; }

I move in silence, Speak with violence, Think with science, Live free and walk with lion.


Wiki Edits: 3
Threads 15
Posts 106

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43



<?php

// je database connectie hier
// ...

$weaponName = ;
$weaponType = ;
$weaponImageId = ;
// enz.

if (isset($_GET['weapenid'])) {

   $result = mysql_query ( "SELECT
       *
       FROM
       weapon
       WHERE
       weapenid = '" . $_GET['weapenid'] . "'");

   if ($result) {
       if ($row = mysql_fetch_assoc( $result )) {
           $weaponName = $row['name'];
           $weaponType = $row['type'];
           $weaponImageId = $row['gfxid'];
       }
   }

}

?>

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


Weapon <?php echo $weaponName ?>



Name:

Type:

<?php echo $weaponName ?>





I move in silence, Speak with violence, Think with science, Live free and walk with lion.


Wiki Edits: 3
Threads 15
Posts 106

Quote:username
<?php

// je database connectie hier
// ...

$weaponName = ;
$weaponType = ;
$weaponImageId = ;
// enz.

if (isset($_GET['weapenid'])) {

   $result = mysql_query ( "SELECT
       *
       FROM
       weapon
       WHERE
       weapenid = '" . $_GET['weapenid'] . "'");

   if ($result) {
       if ($row = mysql_fetch_assoc( $result )) {
           $weaponName = $row['name'];
           $weaponType = $row['type'];
           $weaponImageId = $row['gfxid'];
       }
   }

}

?>

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


Weapon <?php echo $weaponName ?>



Name:

Type:

<?php echo $weaponName ?>





I move in silence, Speak with violence, Think with science, Live free and walk with lion.


Wiki Edits: 3
Threads 15
Posts 106

Okay, Nothing is working.. o_o So any idea on how to display code with out making the php active?

I move in silence, Speak with violence, Think with science, Live free and walk with lion.


Wiki Edits: 3
Threads 15
Posts 106

Okay, Nothing is working.. o_o So any idea on how to display code with out making the php active?

I move in silence, Speak with violence, Think with science, Live free and walk with lion.


Wiki Edits: 0
Threads 12
Posts 52

Haha, i see you are using my code here..

Btw, Zylaxyma its not an intensive work, you can let it generate automatically.

I had a website with a full item db show which only took 5 pages with a small php code.

First page was for example weapon types, then when you select dagger it would get all the weapons out of the database with type dagger, it then can also automatically add the right inv gfx id as the gfx id is shown in the database and same as all the images


Wiki Edits: 3
Threads 15
Posts 106

Lol, Yes I'm guilty. I just wanted to help him out, Cause he was doing what I was if you remember lol.. =P I send Zylaxyma The code. But you should cause I don't remember that code exactly of anything.

I move in silence, Speak with violence, Think with science, Live free and walk with lion.








AWC's: 2.4.3 MediaWiki - Stand Alone Forum Extension