I’m having an issue with implementing a LIKE Button for my website. I’m trying to do a feature whereby when the LIKE button is clicked, the total likes is displayed on the screen
without reloading the page. The code i’m showing below is used to obtain the comments under a specific article, including the likes for each comment. All is working fine at this stage, but how do I pass it to a AJAX/implement an AJAX on the script.
when the LIKE Button is clicked, what link in used in the < a h ref =” ” >?
Is AJAX written alone or inside the PHP?
How do I make it not go away from the current page, while still having the updated likes display from the database?
Please I’m not looking for a do all code, all I need is just how to get myself started with this.
Thanks for your time and effort. I most appreciate it.
Thanks
$query6 = mysql_query("
SELECT
c.user , c.body , c.date, c.like
FROM
comment AS c
INNER JOIN about_ AS ac ON c.article_id = ac.about_id
WHERE
c.article_id = '".$article_id."'
AND page_name = '".$page_name."'
") or die (mysql_error());
It is not that difficult if you do it step by step. I prefer $.ajax as it gives more control over the data sent. Now Modify the above code to suit your need.
And there are more functions you can add above. Read here