0

Create a like button with php mysql ?

I want to make a like button with php..i am simply doing this by : <?php if($_POST['like']) { $sql = "UPDATE post 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> i want to make it like facebook like button so when i click on it on the button refreshes itself not the entire page.

3rd Jul 2019, 2:29 PM
Maaz Masood
Maaz Masood - avatar
3 odpowiedzi
+ 2
You should read about AJAX, which is Asynchronous JavaScript and XML. Using this technology, you can actually dynamically change the content of the current page without refreshing it. Sadly, PHP is a server-sided language, so you can't do that with PHP alone.
3rd Jul 2019, 2:54 PM
Freezemage
Freezemage - avatar
+ 1
done it..thnx @Freezemage
5th Jul 2019, 2:39 PM
Maaz Masood
Maaz Masood - avatar
+ 1
need one more help call you tell me the database structure for each post's likes and comments....its little bit confusing me
5th Jul 2019, 2:40 PM
Maaz Masood
Maaz Masood - avatar