jaynesh — 2011-09-06T07:32:46-04:00 — #1
I am working on a like system for my blog.
So far Ive managed to display all the users that have liked a certain post.
Let's say 5 people have liked my post.
This is how it will be displayed
billy, bob, jacob, sarah, tanya have liked this post.
How can I get it to display something like this instead:
Billy, bob and 3 others have liked this post.
guido2004 — 2011-09-06T10:45:13-04:00 — #2
How are you displaying the 5 users?
jaynesh — 2011-09-06T10:11:17-04:00 — #3
Hi, how would I go about displaying the first two users?
guido2004 — 2011-09-06T08:12:16-04:00 — #4
1) Get the number of selected rows with mysql_num_rows().
2) Subtract 2 from that number.
3) Display only the first two users that liked the post, and then add the 'and n others' part (if the result from #2 is > 0)