JQuery Like & Dislike using Ajax | Lessoncup Programming Blog

Tuesday, 24 September 2013

JQuery Like & Dislike using Ajax

Few days back i worked on one project and the client need a requirement like the user can like & unlike the dynamic posts. for that i implement this lesson using Ajax & Jquery.



index.php

Step 1

add this External script links inside the <HEAD> tag
<link rel="stylesheet" href="style.css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="ajax_likes.js"></script>

Step 2

Create the database polls and create table questions
CREATE TABLE IF NOT EXISTS `questions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `ques` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;

Step 3

In index.php write mysql database connection on top of the page. now i am putting the all posts in loop inside the body tag and top of the div class=ld-container and end the loop at end of the same div now just add action attribute to the same div like action='ajax_likes.php' and add one more attribute to the same div like tid='post<?php echo $full['id'];?>' in that just echo the php value to create the notepad files dynamically and store the like & disLikes.

JQuery Like & Dislike using Ajax

<?php $get=mysql_query("select * from questions"); while($full=mysql_fetch_array($get)){ ?>
<?php echo $full['ques'] ?>
<?php } ?>


Live Demo   Download Script

2 comments :

  1. How do I implement that in blogger posts?

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete

Mohammad Khasim
Blogger | Web Developer
Hyderabad - INDIA
lessoncup@gmail.com

PHP | My SQL | JQUERY
Web Development Tools | CMS | Frameworks | SEO

Get my Latest Lessons