Facebook Jquery Mysql PHP

Facebook style Like System with Jquery, MySQL and PHP.

Facebook like system is one of the best implementation in social network systems, may be in future based on like data Facebook going to launch semantic search engine. In this post I have explained how to implement like/unlike system database design and web implementation with PHP and jquery

Database Design
To build the message conversation system, you have to create three tables such as Users,Conversation and Conversation_Reply. This following image generated by using Mysql Workbench tool.

Users Table

User table contains all the users registration details.

Messages Table

This table contains user status messages data. Here uid_fk  is the FOREIGN KEY to REFERENCES users.uid

Message Like Table

Contains all user message likes relation data. Here uid_fk is FOREIGN KEY to REFERENCESusers.uid and msg_id_fk is FOREIGN KEY to REFERENCES messages.msg_id

HTML Code



Simple HTML code.

PHP Code
To show Like or Unlike from message_like table based on message ID.

PHP Code
This code will display likes users details from users and message_like tables based on message ID.

JavaScript
Contains javascipt code. $(“.like”).click(function(){}- like is the class name of the like/unlike anchor tag. Using $(this).attr(“id”) calling anchor tag ID value.

message_like_ajax.php
Contains PHP code to update Like or Unlike data.

Final PHP Code
Complete Like/Unlike system.

db.php
Database configuration file, modify username, password and database values.