Monkuar Posted January 24, 2015 Share Posted January 24, 2015 (edited) Before reading: I already have a system in place for inventory management. I use it with a rpg_items database with a field called 'item_slot', etc and it works wonderfully. My issue is. I think it would be intuitive if I were to store a basic 20 slot 0 iteration in a field under the users table for each character. So I can just check against that, instead of querying the whole rpg_user_items table, (which will have thousands, hundreds of thousands of users items) to just check if a user's inventory is full, that is not intuitive. I'd rather just check if a field name has no open 0's instead with php. (This ofcourse will be updated dynamically upon a user moving their items to different slots). Let's say I have this array, and it's stored in a field called userinventory in the users table: 0,0,0,0,0 0,0,0,0,0 0,0,0,0,0 0,0,0,0,0 This is pretty easy to read. there is 20 slots, 5 on reach row. That's 20 inventory slots a user has access to. This is supposed to represent something like this: I can store this in the MYSQL field as 'userinventory'. Now, how do I go about dynamically each specific 0 (ZERO) in this Block? I'm going to call this a block. I will need to label it accordingly. Paint time. Here u go How do I use PHP to dynamically update a block like this based upon user input? (A 1, A 2, A3, B2, B1, etc) To check if a user's inventory is full would be easy. I can just explode them by ',' and use count to see if it's greater than 20. My problem is about updating each individual block to represent a users inventory. So, if there is a 1 there, an item would be there. That's all I'm trying to do. I could ofcourse, create what 20 (5x4) if functions to place them at each individual block, but that wouldn't be intuitive and be extremely confusing. Edited January 24, 2015 by Monkuar Quote Link to comment https://forums.phpfreaks.com/topic/294191-inventory-management-storage/ Share on other sites More sharing options...
ginerjm Posted January 24, 2015 Share Posted January 24, 2015 I'm sure that this: store a basic 20 slot 0 iteration makes a ton of sense to you. Not to me. My one comment on something that I do understand - you have a system that stores multiple pieces of the same discrete data item into one field? Well if it works it works, but it is certainly not a RDBMS. Every time you read something you have to break it down into useable values and when you store it you have to reverse that process. Horrible design. Quote Link to comment https://forums.phpfreaks.com/topic/294191-inventory-management-storage/#findComment-1504056 Share on other sites More sharing options...
Monkuar Posted January 24, 2015 Author Share Posted January 24, 2015 (edited) I'm sure that this: store a basic 20 slot 0 iteration makes a ton of sense to you. Not to me. My one comment on something that I do understand - you have a system that stores multiple pieces of the same discrete data item into one field? Well if it works it works, but it is certainly not a RDBMS. Every time you read something you have to break it down into useable values and when you store it you have to reverse that process. Horrible design. Yeah, but that's why I already store the users items in a table and have them for each row. So I don't have to do that. But I'm trying to store the users inventory into a field like this so I don't have to query the rpg_user_items database everytime just to check if a users inventory is full, you know? Hope this helps Edited January 24, 2015 by Monkuar Quote Link to comment https://forums.phpfreaks.com/topic/294191-inventory-management-storage/#findComment-1504060 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.