I have a like system where everytime you click on the favorite the button adds a value to the database with the userid and msgid liked. On page load, it will check what got liked and what didn’t using mysql. If liked it will show the unlike button. But I want to show how many people have liked the msgid. I don’t know how to define the form which is created for the message.
Here is my code:
function listfav($msgid){
$q = mysql_query("SELECT * FROM `fav` WHERE `msgid`='$msgid'");
$q1 = mysql_num_rows($q);
$n = 0;
while($row = mysql_fetch_array($q1)){
$n += 1;
}
return $n.' People favorited this!';
}
1 Answer