Answer the question
In order to leave comments, you need to log in
Is it possible to do this in db?
Hi all. I'm making a "Bookmarks" section on the site, for this I created a table with the fields id, user_id, video_id.
In this section, I will display the videos that the user has added. And the user will add them like this: Near the video there will be an icon of the "Add to bookmarks" type and by clicking on this icon a field will be created in the table of the type id = 1; user_id = 1; video_id 21; But if he adds another video, another field of type id = 2 will be created in the table; user_id = 1; video_id 22; It's not going to be very good. Whether it is possible to make so that only one field was created, for example: id = 1; user_id = 1; video_id = 21; video_id = 22; etc.
How to do this? Or would that be wrong?
Answer the question
In order to leave comments, you need to log in
Before adding, check if the user has added it before, if not, before adding the video to bookmarks
$count = "SELECT COUNT(*) FROM `table` WHERE `user_id` = '$user_id' AND `video_id` = '$video_id'";
if (!$count) {
// добавляем видео в закладки
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question