I have articles in my Article table. How can I manage to count how many times each article visited? I want to show the most visited article on the home page.
add a column "visited" . increment by 1 every time you read the article.
Better yet, create a db table that stores information about articles being read. It would have article_id, datetime_read, and any other fields you deem important.
Add a row to this table whenever someone selects an article.
This will give you access to much more information, such as, what was the most popular article between Date A and Date B.
Marked as answer by Angie xu - MSFT on Dec 16, 2012 11:52 PM
All I understand that when anyone clicks the hyperlink of the article, that article in the table will be UPDATED by increasing the visited. Does it make the site slower?
All I understand that when anyone clicks the hyperlink of the article, that article in the table will be UPDATED by increasing the visited. Does it make the site slower?
Adding database writes to a page will make it slower, but not enough to be noticed. Since you are talking about articles, the part that will take the longest is probably the browser rendering the html output.
ayanmesut
Member
219 Points
85 Posts
most popular
Dec 09, 2012 07:59 AM|LINK
I have articles in my Article table. How can I manage to count how many times each article visited? I want to show the most visited article on the home page.
ignatandrei
All-Star
137649 Points
22143 Posts
Moderator
MVP
Re: most popular
Dec 09, 2012 08:51 AM|LINK
add a column "visited" . increment by 1 every time you read the article.
ayanmesut
Member
219 Points
85 Posts
Re: most popular
Dec 09, 2012 09:28 AM|LINK
I understood that how can I do that: increment by 1 every time you read the article.
Dan Bracuk
Contributor
3970 Points
1096 Posts
Re: most popular
Dec 09, 2012 12:15 PM|LINK
Better yet, create a db table that stores information about articles being read. It would have article_id, datetime_read, and any other fields you deem important.
Add a row to this table whenever someone selects an article.
This will give you access to much more information, such as, what was the most popular article between Date A and Date B.
ayanmesut
Member
219 Points
85 Posts
Re: most popular
Dec 09, 2012 12:38 PM|LINK
All I understand that when anyone clicks the hyperlink of the article, that article in the table will be UPDATED by increasing the visited. Does it make the site slower?
Dan Bracuk
Contributor
3970 Points
1096 Posts
Re: most popular
Dec 09, 2012 12:52 PM|LINK
Adding database writes to a page will make it slower, but not enough to be noticed. Since you are talking about articles, the part that will take the longest is probably the browser rendering the html output.