boots Posted July 5, 2012 Posted July 5, 2012 Im trying to cahnge this line using item_add INSERT INTO inventory (inv_itemid, inv_userid, inv_qty) VALUES (123, :myid:, 1) this is what i have i have. Tried so many ways but still cant get it to work can somone please put me right item_add($userid, $r['itemid 123 ], $r['imQTY 1']); Quote
Djkanna Posted July 5, 2012 Posted July 5, 2012 Little confused, what are you actually trying to do? Quote
boots Posted July 5, 2012 Author Posted July 5, 2012 (edited) The way the line is at the moment it sends the item to the inventory but as single items so i have a list of the same item but i want them to be added to one group i have used item_add before but cant seem to get it to work this time :( the line I want to change is INSERT INTO inventory (inv_itemid, inv_userid, inv_qty) VALUES (123, :myid:, 1) Edited July 5, 2012 by boots Quote
Seker Posted July 5, 2012 Posted July 5, 2012 EDIT: Here's how my function's set up. A bit different, I think, since it's V1, but it adds the right quantity. function item_give($userid, $itemid, $qty, $notid=0) { if($notid > 0) { $q=mysql_query("SELECT * FROM inventory WHERE inv_userid={$userid} and inv_itemid={$itemid} AND inv_id != {$notid}"); } else { $q=mysql_query("SELECT * FROM inventory WHERE inv_userid={$userid} and inv_itemid={$itemid}"); } if(mysql_num_rows($q) > 0) { $r=mysql_fetch_array($q); mysql_query("UPDATE inventory SET inv_qty=inv_qty+{$qty} WHERE inv_id={$r['inv_id']}"); } else { mysql_query("INSERT INTO inventory (inv_itemid, inv_userid, inv_qty) VALUES ({$itemid}, {$userid}, {$qty})"); } } Quote
Djkanna Posted July 5, 2012 Posted July 5, 2012 The way the line is at the moment it sends the item to the inventory but as single items so i have a list of the same item but i want them to be added to one group i have used item_add before but cant seem to get it to work this time :( the line I want to change is INSERT INTO inventory (inv_itemid, inv_userid, inv_qty) VALUES (123, :myid:, 1) If I recall correctly v2's item_add function automatically updates the inv_qty of an item already existing in a users inventory. Mind sharing your item_add function? Quote
boots Posted July 5, 2012 Author Posted July 5, 2012 Yes it does update automatically but i cant remember how to rewite the line INSERT INTO inventory (inv_itemid, inv_userid, inv_qty) VALUES (123, :myid:, 1) instead of insert into inventory i think it should be item_add Quote
Seker Posted July 5, 2012 Posted July 5, 2012 No, the item_add function contains all the inventory inserting you need. If you want to insert two items, you would do: item_add(inv_itemid,inv_userid,2): For three: item_add(inv_itemid,inv_userid,3); Etc, etc. Quote
lucky3809 Posted July 5, 2012 Posted July 5, 2012 no need to put 2 or 3. item_add(inv_itemid,inv_userid,inv_qty); or whatever is in your script that equals the quantity being added. Quote
Uridium Posted July 6, 2012 Posted July 6, 2012 the use of :myid: is part of the searching script that i wrote this just tells the script who had found something at the time of the search Quote
rulerofzu Posted July 6, 2012 Posted July 6, 2012 item_add($userid, $r['itemid 123 ], $r['imQTY 1']); Your issue is this $r[itmid 123'], $r['imQTY 1'] Not how it works your dont specify the itemid and qty there as its already been done in the query before that item_add($userid, $r['itemid], $r['imQTY']); Is all you require for the function. 1 Quote
AnonymousUser Posted November 2, 2012 Posted November 2, 2012 lol thanks zu for some reason i had a brain fart couldnt recall the string xD +1 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.