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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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