I want to make a recipe website.In that I had added the add to favourite button.If i click my favourite button the recipe which i clicked will add to favourites.I i re-click it will remove from my favourites.It is controlled by the status field in the favourites table in sql.How could I do this?

Recommended Answers

All 2 Replies

If you want to delete the recipe from the favourites all together you could do the following

You need 3 tables:

  • UserTable

    • UserID (primary key)
  • RecipeTable

    • RecipeID (primary key)
  • FavouritesTable

    • FavouritesID (primary key)
    • UserID (foreign key)
    • RecipeID (foreign key)

You'll also need 2 stored procedures:

  • Insert
    stored procedure that is executed when the favourite box is and INSERTs a new record with the user's ID and the recipe ID

  • Delete
    stored procedure that is executed when the favourite box is unticked and DELETES a SINGLE record with that user's ID and the ID for that recipe.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.