I created a sort of voting website with PHP and a MYSQL database. People can vote on id's that are in the database and the amount of likes goes up.
When you click on a button the likes of that specific id goes up by one. This is done through Ajax and sql.
Is it possible to set a limitation of the amount of likes an id can have for each day. For instance each id can update only 10 times each day. And the next day another 10 times.
CodePudding user response:
Yes, you can put condition in ajax code. Before inserting record in DB for vote first check the total number of vote received for that ID on current day. If it is equal to 10 then skip the operation or else increase the vote.
Not a big deal i think so.
CodePudding user response:
okay so do you have an idea how to implement that in my code below.
$('.like').on('click', function(){
$(this).addClass('ri-heart-fill');
$(this).removeClass('ri-heart-line');
var postid = $(this).data('id');
var $post = $(this);
$.ajax({
url: '/10jaar/views/submissions.php',
type: 'post',
data: {
'liked': 1,
'postid': postid
},
success: function(response){
$post.parent().find('span.likes_count').text(response " likes");
}
});
});