mixmaster Posted September 19, 2011 Share 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 Link to comment Share on other sites More sharing options...
Uridium Posted September 19, 2011 Share Posted September 19, 2011 if the user has 500+ items that dropdown box could become rather larger Quote Link to comment Share on other sites More sharing options...
mixmaster Posted September 19, 2011 Author Share 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 Link to comment Share on other sites More sharing options...
mixmaster Posted September 19, 2011 Author Share Posted September 19, 2011 urm bump ??? Quote Link to comment Share on other sites More sharing options...
extra Posted September 19, 2011 Share 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 Link to comment Share on other sites More sharing options...
bineye Posted September 19, 2011 Share 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 Link to comment Share on other sites More sharing options...
Uridium Posted September 20, 2011 Share 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 Link to comment Share on other sites More sharing options...
Uridium Posted September 20, 2011 Share Posted September 20, 2011 cheers matey :) 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.