This is my MySQL table:
- The left column auto increments.
- The center column is the id# of the user.
- The right column is the id# of a post that they like.
I am inserting data into the table like so:
$stmt = $db->prepare("INSERT INTO likes (user_id,post_id) VALUES (?,?)");
$stmt->execute(array($_SESSION['user'],$_POST['id']));
This works fine, but as you can see the MySQL table has two identical rows (id's 3 & 4) which both have a user_id of 5 and a post_id of 196. In other words my MySQL table records that the user with id = 5 likes the post with id = 196 two times. how do I disallow a situation where there are two rows that have identical user_id's and identical post_id's