Welcome to the Treehouse Community
Looking to learn something new?
Hi Guys, I'm struggling creating a website for a client where, the user can choose an item and block from other users
Basically the idea is that the user will go to a page where there will be items displaying in an image gallery(just like an online shop) where the user can select one item(#item), click the corresponding button(#btn) below the image and select that item for his own and prevent other users from selecting by disabling the button. So just wondering what would be the best option, and i guess it would be using jquery with $('#btn').click() , addClass to disable #btn then i guess save it using PHP? that is as far as I can think of solving it but if someone can guide me on how to do this? i would be deeply grateful! :)
Hugo Paz15,620 Points
My suggestion is as follows. You have all items on a database with all corresponding fields, id, name, image and a field called available. By default all items are available. Once a user clicks on an item, it gets registered on the database as not available, you also need to save the user on that table.
When you get the items from the database to display, you do a simple check, is it available or not. If yes, just add the normal button. If its not available, you show a disabled button.