You'd need to update your SELECT query to only count the views in the last 3 days from the current day. That way any view that's older than 3 days from current day isn't counted and if there is none it'd return 0. You don't need to reset anything.
Kyle (Krileon) Community Builder Team Member Before posting on forums:
Read FAQ thoroughly
+
Read our Documentation
+
Search the forums CB links:
Documentation
-
Localization
-
CB Quickstart
-
CB Paid Subscriptions
-
Add-Ons
-
Forge
-- If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
-- If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please
send me a private message
with your thread and will reply when possible!
-- Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
-- My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
SELECT COUNT(viewer_id) AS nombrevisiteurs FROM #__comprofiler_views WHERE profile_id=[user_id] AND DAY(NOW()) - DAY(lastview) < 3 AND viewer_id!=0 LIMIT 30
Your query isn't correct. You need to check that lastview is equal to or greater than 3 days from now. Using DAY is just pulling the day value from the datetime value and isn't accurate calculation. The below should work.
Code:
SELECT COUNT(*) FROM `#__comprofiler_views` WHERE `profile_id` = '[user_id]' AND `lastview` >= DATE_SUB( NOW(), INTERVAL 3 DAY ) AND `viewer_id` != 0 LIMIT 30
The above will return the view count for a user as long as the views were logged within the last 3 days from now.
Kyle (Krileon) Community Builder Team Member Before posting on forums:
Read FAQ thoroughly
+
Read our Documentation
+
Search the forums CB links:
Documentation
-
Localization
-
CB Quickstart
-
CB Paid Subscriptions
-
Add-Ons
-
Forge
-- If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
-- If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please
send me a private message
with your thread and will reply when possible!
-- Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
-- My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.