PHP/MySQL Like Button
I've made a 'like' button for my product pages with this code:
Hello Friends in this tutorial we will develop for like button by using PHP and Mysql. For demonstrating this feature I have put like button under Article title, the user can like that article and one user can like only one time, if he like same article second time, then he will not like the article. If you want to put this type of function in your current project then you can first learn how we can make this type of like button. If you are working in the content management system and in that system, you want to display popularity of any article like how many people has like that article, from this thing you can display the popularity of that article.
For this things you can put like button below that article for a user can like that article. In this video, I will explain how to implement like button system database design and web implementation with PHP and myself. This is my simple like button script in which user can like multiple articles only single time, if he again like that article then it will not able like that article. I have used simple PHP code with MySQL query for inserting articles like data like user id and article id into a table. In this script, we can display how many user has like the particular article and we can also see the name of the user who was like the particular article.
Solution 1
<?phpif($_POST['like']) {
$sql = "UPDATE table set `likes` = `likes`+1 where `product_id` = '1'";
$result=mysql_query($sql);
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="POST"><input type = "submit" value = "like" name='like'/>
</form>
For this things you can put like button below that article for a user can like that article. In this video, I will explain how to implement like button system database design and web implementation with PHP and myself. This is my simple like button script in which user can like multiple articles only single time, if he again like that article then it will not able like that article. I have used simple PHP code with MySQL query for inserting articles like data like user id and article id into a table. In this script, we can display how many user has like the particular article and we can also see the name of the user who was like the particular article.
Solution 2
<!-- LikeBtn.com BEGIN -->
<span class="likebtn-wrapper" data-identifier="item_1"></span>
<script>(function(d,e,s){if(d.getElementById("likebtn_wjs"))return;a=d.createElement(e);m=d.getElementsByTagName(e)[0];a.async=1;a.id="likebtn_wjs";a.src=s;m.parentNode.insertBefore(a, m)})(document,"script","//w.likebtn.com/js/w/widget.js");</script>
<!-- LikeBtn.com END -->
https://likebtn.com/en/like-button-php
No comments