I have a like system on my site
<p>I have a like system where everytime you click on the favorite the button adds a value to the database with the <code>userid</code> and <code>msgid</code> 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 <code>msgid</code>. I don't know how to define the form which is created for the message.</p>

<p>Here is my code:</p>

<pre><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!';
}
</code></pre>
