Jump to content

PHP/SQL Help!


Thisnamewilldo

Recommended Posts

Hello, thank you for taking the time to read this.

 

Basically, I have a table in a mySQL database that holds people's inventory on a game and it is stored like this :

 

[2(17:0)x1]

[slotID(ItemID:ItemValue)xAmount]

 

:wtf:

 

I also have another table which stores the hundreds of available items.

 

I need it so that I can do something like:

 

<?
$checktheiritem = mysql_query("SELECT * FROM inventory WHERE owner='$logged[username]'");
while ($theiritem = mysql_fetch_array($checktheiritem)) {
$amount = AMOUNT;
// AMOUNT would need to be the amount from the inventory table.
$getitem = mysql_query("SELECT * FROM items WHERE itemid = 'ITEMID'");
// ITEMID would need to be the item id from the inventory table.
$item = mysql_fetch_array($getitem);
echo "$item[name] x $amount";
}
?>

 

Does anyone have any idea how I can separate the amount, itemid, item value etc from the one result [slotID(ItemID:ItemValue)xAmount]?

 

I tried doing this, my code is below.. but as you can imagine, it is having to check the hundreds of items first which takes about 10 seconds for the script to load. Also I still cannot get the amount.

 

<?
$getitem = mysql_query("SELECT * FROM items");
while ($item = mysql_fetch_array($getitem)) {
$checktheiritem = mysql_query("SELECT * FROM inventory WHERE owner='$logged[username]' AND inventory LIKE '%($item[itemid]:$item[value])%'");
$theiritem = mysql_fetch_array($checktheiritem);
if ($theiritem != NULL) {
echo "$item[name]";
}
}
?>

 

Any help at all would be appreciated!

 

Thanks,

Vince.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.