Jump to content
MakeWebGames

quantify help


boots

Recommended Posts

Im trying to change this so they dont add to the inventory as single items

 

if($r['rewardtype'] == 3)
{
$juk=mysql_query("SELECT * FROM items WHERE itmid=$reward",$c);
$item=mysql_fetch_array($juk);
mysql_query("INSERT INTO votes values ($userid,$id)",$c);



mysql_query("INSERT INTO inventory values ('',$reward,$userid,1)",$c);  <<<<<<<<<< this line

event_add($userid,"Thank you for voting! You have receieved a/an {$item['itmname']}!", $c);
}
if($r['rewardtype'] == 4)

 

this is what i have so far but still cant get it to work

 

if($r['rewardtype'] == 3)
{
$juk=mysql_query("SELECT * FROM items WHERE itmid=$reward",$c);
$item=mysql_fetch_array($juk);
mysql_query("INSERT INTO votes values ($userid,$id)",$c);


item_add($userid,$reward,1)",$c);

event_add($userid,"Thank you for voting! You have receieved a/an {$item['itmname']}!", $c);
}
if($r['rewardtype'] == 4)
Link to comment
Share on other sites

The script is for my voting page i have items as rewards for voters , the problem is when items are given they go in the inventory as single items. i want them to group together instead of loads of single items if they get a will potion then it adds to the rest of the will potions not a long list of potions

Link to comment
Share on other sites

$used=array();

$q=mysql_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'];

$q2=mysql_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'];

}

mysql_query("DELETE FROM inventory WHERE inv_id IN(".implode(",",$currdel).")");

mysql_query("INSERT INTO inventory VALUES('', {$r['inv_itemid']}, $userid, $amount)");

}

}

this might help aswell,

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.

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