Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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,622 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.