Jump to content

[share] PHP inventory check (Admins tool)


Recommended Posts

Posted

So here is a code to fastly check characters inventory through the web.

 

Post form for charname input :

 

<form action='invent.php' method='post'> 
<input type='text' class='ainput'  name='charname' value='Char name' /> 
<input type='submit' class='abutt' name='Submit' value='Get Inventory'/> 
</form> 

 

Conect to database:

 

<?php 
$host="localhost"; // Host name  
$dusername="root"; // Mysql username  
$dpassword="пароль"; // Mysql password  
$db_name="stable"; // Database name  
mysql_connect("$host", "$dusername", "$dpassword")or die("cannot connect");  
mysql_select_db("$db_name")or die("cannot select DB"); 
?>

 

Inventory query (dowload items icons images and put to /items/ folder,):

 

include('connect.php'); 
$charname = $_POST['charname']; 
$query = "SELECT * from characters WHERE char_name = '$charname'"; 
$result=mysql_query($query) or die ('Error:' .mysql_error()); 
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) 
    { 
  $accid = $row['obj_Id']; 
  } 
$query1 = "SELECT * from items WHERE owner_id = '$accid'"; 
$result1 = mysql_query($query1) or die ('Error:' .mysql_error()); 
Echo "  
<div id='topa'>$charname INVENTORY</div> 

<table> 
  <tr><td>Item</td> 
  <td>Count</td> 
  <td>Enchant</td> 
  <td>Location</td> 
   
  </tr> 
   
  "; 
while($row = mysql_fetch_array($result1, MYSQL_ASSOC)) 
    { 
  $itemid = $row['item_id']; 
  $count = $row['count']; 
  $enchant = $row['enchant_level']; 
  $loc = $row['loc']; 
  echo " 
  <tr> 
  <td><img src='items/$itemid.gif'/></td> 
  <td>$count</td> 
  <td>$enchant</td> 
  <td>$loc</td> 

  "; 
  } 
echo "</table>"; 

 

Ofc SS:

ce5ff6c9ffc8a2a7bc0048bdd3ec67d5772.jpg

 

Credits to me.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..