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 questionsCREATE 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 } ?><?php echo $full['ques'] ?>![]()
![]()
Live Demo Download Script
How do I implement that in blogger posts?
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteOld. Do not supports PHP v.7.2
ReplyDelete