mixmaster Posted September 19, 2011 Posted September 19, 2011 how to get a drop down box of a users inventory (so the user can just drop the box down and see what is in there inventory) ? i have tried creating another function in "global_func" but cant get it to work lol , thanks in advance Quote
Uridium Posted September 19, 2011 Posted September 19, 2011 if the user has 500+ items that dropdown box could become rather larger Quote
mixmaster Posted September 19, 2011 Author Posted September 19, 2011 if the user has 500+ items that dropdown box could become rather larger hmmm good point , i would have to deal with that when the time comes lol Quote
extra Posted September 19, 2011 Posted September 19, 2011 Well just create a dropdown in html and retrieve the data from the databases. I don't know how mccodes code is structured so I can't really help you with that. Also as far as having too many items per dropdown. Make an individual dropdown for each i.e. one for weapons, one for armor, etc, etc, Quote
bineye Posted September 19, 2011 Posted September 19, 2011 I'm guessing something like: <td valign=top>Inventory:</td> <td> <?php $sql_query=("SELECT itmname FROM inventory WHERE userid=$userid"); echo "<select name='item'>"; if(mysql_num_rows($sql_query)) { while($row = mysql_fetch_assoc($sql_query)) { echo "<option>$row[itmname]</option>"; } } else { echo "<option>No Items In Inventory!</option>"; } ?> </td> </tr> Quote
Uridium Posted September 20, 2011 Posted September 20, 2011 (edited) Hope this helps.. Add to global_func.php function inv_item_dropdown($connection,$ddname="userinv",$selected=-1) { global $db,$r,$ir; $ret="<select name='$ddname' type='dropdown'>"; $q=$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=".$ir['userid'].""); if($selected == -1) { $first=0; } else { $first=1; } while($r=$db->fetch_row($q)) { $ret.="\n<option value='{$r['itmname']}'"; if ($selected == $r['itmname'] || $first == 0) { $ret.=" selected='selected'";$first=1; } $ret.=">{$r['itmname']} <b>You Have ({$r['inv_qty']}) Of This Item</b></option>"; } $ret.="\n</select>"; return $ret; } then add anywhere near top of inventory.php print "<h3>Inventory Quick View</h3><br /> ".inv_item_dropdown($c,'userinv')."<br />"; Should list Items you have by name and Quantity Edited September 20, 2011 by illusions 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.