ecabrera Posted May 12, 2012 Share Posted May 12, 2012 Ok i want it to make it that everything some clicks on a view the view goes up by one so i did this <?php session_start(); $views = $_SESSION['views']++; ?> and echo the views like this Views<?php echo $views; ?> but it updates countines to add even if the video is a new video Quote Link to comment https://forums.phpfreaks.com/topic/262453-views/ Share on other sites More sharing options...
ecabrera Posted May 12, 2012 Author Share Posted May 12, 2012 can anyone help me Quote Link to comment https://forums.phpfreaks.com/topic/262453-views/#findComment-1345028 Share on other sites More sharing options...
noXstyle Posted May 12, 2012 Share Posted May 12, 2012 Hi. Can you try to be a bit more specific? Or try to express yourself a bit more clearly? The way I understood this is that you are trying to create a view counter for videos. Am I correct? Or are you trying to get the amount of views a specific person has viewed a single video? Anyway: what your code does it increments the counter each time the code block is executed. If you want to get the views for specific videos you should for example assign a video ID or something similar to the view array. $views = $_SESSION['views'][videoID']++; In that way it increments the counter for a specific video, when user views another video another video ID is being incremented. In case you want to get the total views, you should increment database view counts rather than session values. Hope this makes any sense. Quote Link to comment https://forums.phpfreaks.com/topic/262453-views/#findComment-1345030 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.