Jump to content

[share] PHP inventory check (Admins tool)


Meikis

Recommended Posts

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.

Link to comment
Share on other sites

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.



×
×
  • Create New...