Jump to content
Sign in to follow this  
mixmaster

Does anyone know

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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,

Share this post


Link to post
Share on other sites

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>   

Share this post


Link to post
Share on other sites

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 by illusions

Share this post


Link to post
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.

Sign in to follow this  

×
×
  • Create New...