Hello there, On my website, I have a table "movies" and a table "users" Now the simple thing I'm trying to do is that a user can simply click a "Add to favs" button, and it adds that movie to his favorite (ajax / javascript not necessary at the moment, just php) So what's the simplest way I could do something like that? I thought about it many times but I can't seem to find a solution (all I think of is way too complicated, and imo not possible) What's your thoughts? I dont ask for anything pre-made, just an idea that could get me working. (Although if you have an example of such script, I'd be happy to look at it) Thanks to anyone!
Add another field into the users called fav or something like that, then when they click add to fav add the movie id to that field, if theres one in there already take the value out, make it like 1,4 and update the table. When your displaying it use explode to split them up. Glen
on your users table add new column that will hold all the users faved or a new table for holding the data, simply add a new form that will submit users that favs a movie. this is a simple flow so dont get this too much complicated.
Don't add new Rows. To ensure that there is no data duplication, and to ensure that the database is normalised, you will need to create a new table on your database. When a user likes a video, the user ID, and the Video ID should go into this new table. Both the video and user tables should have an ID as their primary key, and the adjoining table should have a concatenated primary key of the two ID's, and this will never be the same, and means the new table will only need two rows. I know database normalisation if you need help with it.