0

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?

3
Contributors
2
Replies
17
Views
4 Years
Discussion Span
Last Post by kaustavbanerjee
0

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.

Edited by ChrisHunter

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.