I have a page that displays all books and their descriptions, there is a button like on every book displayed. So the idea is when a user logs in the user will see all the books displayed, the user can make his or her choice by clicking the button like. Now i have successfully done that, the remaining thing for me in that code is to sum all the likes attributed to each book, for example looking at the table below you can see that 4 users liked 4 different books, mic and pap44 liked two books, cooking33 and ASP55 that means the sum for like count should be ASP55 - 2 while cooking33 gets 1, Drama44 gets 1 and Fishing5 gets 1 This is the code i use to sum it, so my problem is that the code is not summing it up well based on each book usernames.
the logic goes like this, mic33 likes cooking101 book that gives cooking101 1 count so if cooking101 logs in to his page he sees the usernames and count of those who liked his book so in this case its only mic33 - count 1.
In the case of stevbook88 two people liked his books mic33 and cooking101, so if stevbook88 logs in his page he sees the usernames of mic33 and cooking101 - count 2.
Users table
ID UserName Names
------------------------------------------------
1 mic33 mic
----------------------------------------------------
2 stevbook88 steve book
--------------------------------------------------------
3 kanv44 kan
---------------------------------------------------------
4 Cooking101 Cooking
---------------------------------------------------------
Dm_favorite table blow
ID UserName BookUserName Count
----------------------------------------------------------------
1 mic33 cooking101 1
----------------------------------------------------------------
2 cooking101 stevbook88 1
----------------------------------------------------------------
3 mic33 stevbook88 1
----------------------------------------------------------------