Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP

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! :)

1 Answer

Hugo Paz
Hugo Paz
15,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.