DEA Posted June 10, 2009 Posted June 10, 2009 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 Quote
Rainbow Posted June 10, 2009 Posted June 10, 2009 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(); ?> Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.