Jump to content
MakeWebGames

Recommended Posts

Posted

Looking for a mod to pile up the items in inventory. right now every item is listed by itself...need to be able to group them all I.E Bat x 10

Posted

Re: Need a "pile items" in inventory

It would not hurt to use the search function once in a while. Something I found - not tested, but looks like it should work fine. :)

 

<?php
include( "globals.php" );
$used=array();
$q=$db->query("SELECT * FROM inventory WHERE inv_userid=$userid");
while ( $r=mysql_fetch_array($q) ) {
if ( ! in_array ( $r['inv_id'], $used ) )
{
$currdel=array();
$used[] =$r['inv_id'];
$currdel[]=$r['inv_id'];
$amount=$r['inv_qty'];
//grab sellers others
$q2=$db->query("SELECT * FROM inventory WHERE inv_userid=$userid AND inv_itemid = {$r['inv_itemid']} AND inv_id != {$r['inv_id']}");
while ( $r2 = mysql_fetch_array($q2) ) {
$used[]=$r2['inv_id'];
$currdel[]=$r2['inv_id'];
$amount+=$r2['inv_qty'];
}
//if($userid == 1)
//print "DEBUG: DELETE FROM inventory WHERE inv_id IN(".implode(",",$currdel).")
";
$db->query("DELETE FROM inventory WHERE inv_id IN(".implode(",",$currdel).")");
//if($userid == 1) 
//print "DEBUG: INSERT INTO inventory VALUES('', {$r['inv_itemid']}, $userid, $amount)
";
$db->query("INSERT INTO inventory VALUES('', {$r['inv_itemid']}, $userid, $amount)");
print "$amount of item id {$r['inv_itemid']} Merged...
";
}
}
print "[b]<font color='red'>Items Merged</font>[/b] 


<center><a href=inventory.php>>Back to your Items</a>
";

$h->endpage(); 

?>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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...