raynard Posted July 14, 2010 Share Posted July 14, 2010 I have a problem with my quantifier and i cant seem to fix it, it will quantify items bought or sent but if they are found searching streets they stay as many single items if anyone could help i would be grateful here is my inventory.php <?php include "globals.php"; $q=$db->query("SELECT * FROM items WHERE itmid IN({$ir['equip_primary']}, {$ir['equip_secondary']}, {$ir['equip_armor']})"); print ' <div class="inventory_container"><div class="inventory_topbg"> '; while($r=$db->fetch_row($q)) { $equip[$r['itmid']]=$r; } print ' <div class="generalinfo_txt"> <div>[img=images/info_left.jpg]</div> <div class="info_mid"><h2 style="padding-top:10px;"> Equipped Items</h2></div> <div>[img=images/info_right.jpg]</div> </div> <div class="generalinfo_simple"> <table width="80%" class="table" style="text-align: center;"> <tr> <th>Primary Weapon</th> <td> '; if($equip[$ir['equip_primary']]['itmid']) { print $equip[$ir['equip_primary']]['itmname']."</td><td>[url='unequip.php?type=equip_primary']Unequip Item[/url]</td>"; } else { print "None equipped.</td><td></td>"; } print "</tr> <tr> <th>Secondary Weapon</th> <td>"; if($equip[$ir['equip_secondary']]['itmid']) { print $equip[$ir['equip_secondary']]['itmname']."</td><td>[url='unequip.php?type=equip_secondary']Unequip Item[/url]</td>"; } else { print "None equipped.</td><td></td>"; } print "</tr> <tr> <th>Armor</th> <td>"; if($equip[$ir['equip_armor']]['itmid']) { print $equip[$ir['equip_armor']]['itmname']."</td><td>[url='unequip.php?type=equip_armor']Unequip Item[/url]</td>"; } else { print "None equipped.</td><td></td>"; } print "</tr> </table> <h2 style='padding-top:10px;'> Inventory</h2> "; $inv=$db->query("SELECT iv.*,i.*,it.* FROM inventory iv LEFT JOIN items i ON iv.inv_itemid=i.itmid LEFT JOIN itemtypes it ON i.itmtype=it.itmtypeid WHERE iv.inv_userid={$userid} ORDER BY i.itmtype ASC, i.itmname ASC"); if ($db->num_rows($inv) == 0) { print "[b]You have no items![/b]"; } else { print "[b]Your items are listed below.[/b] <table width=100% class=\"table\" border=\"0\" cellspacing=\"1\"> <tr> <th >Item</th> <th >Sell Value</th> <th >Total Sell Value</th> <th >Links</th> </tr>"; $lt=""; while($i=$db->fetch_row($inv)) { if($lt!=$i['itmtypename']) { $lt=$i['itmtypename']; print "\n<tr><th colspan=4>[b]{$lt}[/b]</th></tr>"; } if($i['weapon']) { $i['itmname']="<font color='red'>*</font>".$i['itmname']; } if($i['armor']) { $i['itmname']="<font color='green'>*</font>".$i['itmname']; } echo "<tr><td>".$i['itmname'].""; if ($i['inv_qty'] > 1) { echo "x".$i['inv_qty'].""; } print "</td><td>\${$i['itmsellprice']}</td><td>"; print "$".($i['itmsellprice']*$i['inv_qty']); $usershop=$db->query("select * from usershops where userid=$userid"); if(mysql_num_rows($usershop)!=0) { $addtoshop="[[url='addtoshop.php?ID={$i[']Put in Shop[/url]]"; } print "</td><td>[[url='iteminfo.php?ID={$i[']Info[/url]] [[url='itemsend.php?ID={$i[']Send[/url]] [[url='itemsell.php?ID={$i[']Sell[/url]] [[url='imadd.php?ID={$i[']Add To Market[/url]] $addtoshop"; $usershop=$db->query("select * from usershops where userid=$userid"); if($i['effect1_on'] || $i['effect2_on'] || $i['effect3_on']) { print " [[url='itemuse.php?ID={$i[']Use[/url]]"; } if($i['weapon']) { print " [[url='equip_weapon.php?ID={$i[']Equip as Weapon[/url]]"; } if($i['armor']) { print " [[url='equip_armor.php?ID={$i[']Equip as Armor[/url]]"; } print "</td></tr> "; } print "<tr><th colspan=4></th></tr></table>"; print "[size="1"][b]NB:[/b] Items with a small red [/size]<font color='red'>*</font>[size="1"] next to their name can be used as weapons in combat. Items with a small green [/size]<font color='green'>*</font>[size="1"] next to their name can be used as armor in combat.[/size] </div><div>[img=images/generalinfo_btm.jpg]</div> </div></div></div></div></div> "; } $h->endpage(); ?> Quote Link to comment Share on other sites More sharing options...
Analog Posted July 14, 2010 Share Posted July 14, 2010 the problem is not in your inventory... Check the file for your searching streets feature and see if it use the function item_add when giving the item Quote Link to comment Share on other sites More sharing options...
raynard Posted July 14, 2010 Author Share Posted July 14, 2010 there is no function_add its in this array $common = mysql_query("SELECT * FROM `items` WHERE `itmid`='".$ri[$ria]."' LIMIT 1"); $rip = mysql_fetch_array($common); $query13=sprintf("INSERT INTO inventory VALUES('',$ri[$ria],$userid,1)",$c); $db->query($query13); $sritemf = $sritemf + 1; could this be the problem Quote Link to comment Share on other sites More sharing options...
Analog Posted July 14, 2010 Share Posted July 14, 2010 Its inserting the item into the players inventory without first checking if the player already has that item. item_add function from global_func.php function item_add($user, $itemid, $qty, $notid=0) { global $db; if($notid > 0) { $q=$db->query("SELECT * FROM inventory WHERE inv_userid={$user} and inv_itemid={$itemid} AND inv_id != {$notid}"); } else { $q=$db->query("SELECT * FROM inventory WHERE inv_userid={$user} and inv_itemid={$itemid}"); } if($db->num_rows($q) > 0) { $r=$db->fetch_row($q); $db->query("UPDATE inventory SET inv_qty=inv_qty+{$qty} WHERE inv_id={$r['inv_id']}"); } else { $db->query("INSERT INTO inventory (inv_itemid, inv_userid, inv_qty) VALUES ({$itemid}, {$user}, {$qty})"); } } Quote Link to comment Share on other sites More sharing options...
raynard Posted July 14, 2010 Author Share Posted July 14, 2010 Thank you +1 for making me realise how much of a noob i am, search the streets has been updated and all items where they should be thanx Quote Link to comment Share on other sites More sharing options...
Zero-Affect Posted July 14, 2010 Share Posted July 14, 2010 yeah there's no need for stuff like merge when you use the right functions Quote Link to comment Share on other sites More sharing options...
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.