Jump to content

Dynamically displaying a saved user choice


dlcmpls

Recommended Posts

Hi all.  I have a problem that has stumped me.

 

I have a web page that displays a list of businesses (pulled from a mysql db).  On that page is a check box that, when ticked, allows the user to save that business for later review.  So let's say my page shows 5 businesses.  The user may want to save 1, 3, or all of the businesses.  Saving the businesses works fine for me.

 

Here's where I get stuck.  I want the page to recognize when a user has already saved a business.  So for example, if the user has already saved Business3, I want to replace the "save it" check box with a text message that says something like "You have already saved this business."  I don't know how to make this happen.

 

I don't really need coding help,  I need an explanation of how I would conceptually do this sort of thing.

 

Thanks

 

dlc

It all rather depends on your exising set up as to how you would approach this. Personally, i'd aim to have an array of previously saved businesses (perhaps storing a unique id for each of them) taken from the database.

 

Then, i would have a loop to output all of the businesses' info, with the option to save. Inside this loop i would check to see if the current business id is in the array of previously saved businesses. If it is, you display "already saved" if its not, you display the checkbox.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.