MySQL vote / message system

I searched for this in stackoverflow, and although I found something in this direction, I did not find anything that really helped me, so I will ask the question myself.

So, I am trying to implement a similar button for images on my website. But I am a little at a loss to understand how this happens.

So far, I have this on the SQLI side:

CREATE TABLE if not exists `likes` (
         `id` int(11) NOT NULL AUTO_INCREMENT,
         `image_id` varchar(300) NOT NULL,
         `liker_username` varchar(50) NOT NULL,
          `liked_unliked` enum('0','1') NOT NULL, DEFAULT '0'
           PRIMARY KEY (`id`)
        );

Where idis the identifier, image_idis the identifier of the image you like, liker_usernameis the name of the user who clicked the button, liked_unlikedis whether the user liked the image (1 for liked, 0 for unliked [so that users vote only once]).

I have image_id already saved in the table photos.

liker_username image_id, , .

... ? , , , , . .

+4
1

, .

, users liker_user_id likes. , images.

, , IP- , . IP- :

$_SERVER['REMOTE_ADDR'];
+1

Source: https://habr.com/ru/post/1542215/


All Articles