PHP - Track Video Views By User
So i have a bunch of random videos playig one after the other what i want is to track if the user viewed the videos by inserting a view lets say in to the database, so if they view the first video the database will increment by 1 then after the page refreshes and the next video loads it will increment again, the only part i dont know what im doing is how would i know if my user viewed the video, any help please thank you?
Similar TutorialsThis topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=313049.0 Hello friends, I am new to PHP and have developed a website... i am stuck at one place. I want to know if the user changes the url in the adress bar and goes to another webpage.. Can we detect that? This is very important for my website because I calsulate the duration of login based on whether user goes to another page or logs out. Ok i want it to make it that everything some clicks on a view the view goes up by one so i did this Code: [Select] <?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 hii i want to create a script where i want to store unique page views per 24 hrs using cookie.. i had create a code but rectify me if i'm wrong... 1) i wan to store a cookie so i set this code on top to create a cookie on views browser.. Quote <php setcookie("user", time()+84600); ?> 2) Now i want to find that if the cookie was set before, then the views will not update, if not then it will increase by 1. Quote <php if (isset($_cookie["user"])) echo "Total no of views" . $views . "; else echo" $views=$views+1; echo " $views"; $k=mysql_query("UPDATE `images` SET views = '$views' WHERE id = '$userid'") ?> but the problem i'm facing is that where to put that "$views" so that it will increase and will show to the user... now suppose every thing works well then how the cookie will understand that the views will be updated in specific users database... please guys i really need help... If some other possible ways are there then please refer... Thanks in advance.. Hello folks, good day! I'm having trouble here selecting my desired data. I hope somebody will help me. Im having two tables. tbl_a seId course year 1 IT 1999 2 HE 1992 3 RT 1990 tbl_b id seId status 1 1 NO 2 2 YES I want to select A.*,B.* from tbl_a AS A, tbl_b AS B having status = NO and status IS NULL my desired output is to see the following. course year status IT 1999 NO RT 1990 is it possible? thank you in advance. Hi,
i am a student for a school.
we have in each class a book that lists the shool year. Teachers use it to make notes in it and mark people that are not present.
i want to bring that whole process online making a website out of it.
Teachers can log in and see the yearbook. Days view, Week view, Month view. Mark people that have been missing on a specific day. List all the people that have been missing during a school week.
How would i present the Calender? Tables?
I have the some knowledge in mysql, php and joomla.
How would i go about getting startet? Do i need to have a Framework?
All ideas would be greatly appreciated.
Thank you
Hi,
I have a blog which records the amount of views on each article. I now want to be able to work out the average number of views per hour.
How can I work out the number of hours passed from a datetime format?
From there I can just do views divided by hours passed.
Thanks in advance!
hey guys im trying to make a page statistics, where i get a view count of certian pages users visit.
now im after a bit of advise on how the best way to achieve this
here are my tables:
CREATE TABLE IF NOT EXISTS `statistics` ( `statistic_id` int(11) NOT NULL AUTO_INCREMENT, `statistic_page_id` int(11) NOT NULL, `user_id` int(11) NOT NULL, `reference_id` int(11) NOT NULL, `ip_address` varchar(15) NOT NULL, `created_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`statistic_id`) ) CREATE TABLE IF NOT EXISTS `statistic_pages` ( `statistic_page_id` int(11) NOT NULL AUTO_INCREMENT, `page_name` varchar(90) NOT NULL, `created_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`statistic_page_id`) )what i was thinking is when a user views the page it will check if user has already visited in the database SELECT user_id FROM statistics WHERE user_id = '1' OR ip_address = INET_ATON('1.1.1.1') AND statistic_page_id = '1' AND refernce_id = '10'if user or guest hasnt visited then add to database INSERT INTO statistics (statistics_page_id, user_id, refernece_id, ip_address, created_timestamp) VALUES ('1', '1' '10', INET_ATON('1.1.1.1'), UTC_TIMESTAMP())statistics_page_id, would be the id representing a page ie. ITEMS and reference_id would be the id of the ITEM any advise on a better way on how it should be done would be super...cheers guys hii i had created a site but i'm facing one problem. where users had to show there page to earn money... like 1000 imp/1$. but what happened is that when ever page reloads in same browser with same ip, it gaining impression. is there any way that i can limit 1 impression per ip in 24 hours... Any help will be appreciated... Currently on my website i record the statistics, for my pages they include unique views, and total page views. at the moment every time a visitor loads a page a script updates a MySql Db. This seems very resource intensive, is there a better way to record statistics?? Hiii i got a image hosting script but the problem i'm not able to solve is that in the show image page, the page views counter is not showing unique views. If we refresh the page 100 times from same ip, it shows (views=100)... Can any one help me with it... The views are stored in the database of the respective users... can anyone help me to get unique views per 24 hrs per ip.... The code is... Quote //UPDATE VIEWS COUNT AND LAST ACCESS DATE $views = $row['views'] + 1; $access = date("y-m-d"); $r = mysql_query("UPDATE `images` SET views = '$views', access = '$access' WHERE id = '$id' "); $imguserid = getUserId($id); $own = false; if ($imguserid != -1) { if ($userid == $imguserid) $own = true; $r = mysql_query("SELECT username FROM `members` WHERE id = '$imguserid'"); $row1 = mysql_fetch_row($r); $username = $row1[0]; } else $username = "Anonymous"; echo "<center>"; echo "<br><LABEL id='title'>Views:</LABEL> $views"; echo "<br><LABEL id='title'>Date Added:</LABEL> {$row['date']}"; if needed i can supply the full script to the person who can help me... You can check the demo in [ http://torrentz.0fees.net/wussa/show-image.php?id=c7693c02c3ad2fafe5f5d3f00263a68a ] The full page is attached below.... If anybody could give me code for that gets site views, that would be really nice. I have a site where people vote, currently if two computers that are on the same network vote, my site will see them as one computer because I only track people by IP address. What would be a good way to track 2+ computers with the same IP address? I've made a template system, but the way I've chosed to do it doesn't give me the ability to choose a design. I've posted the code below with a bad solution for my design problem. Does anyone have any suggestions how to make a very simple and smart templatesystem? I don't have any problems coding. I just need ideas :-) Code: [Select] <?php final class View implements IView { protected $filename, $variables = array(); public function __construct($filename = null, $variables = array()) { $this->filename = $filename; $this->variables = $variables; } public function __toString() { if(!file_exists($this->filename)) { throw new Exception("View does not exists."); } $content = file_get_contents($this->filename); foreach($this->variables as $variable => $value) { $content = str_replace("#{{$variable}}", $value, $content); } return str_replace("#{content}", $content, file_get_contents("design.html")); } } ?> I am building a site using PHP, OOP, and an MVC framework. i am not using laravel, codeignitor, or any other framework, I am building this on my own. I am a newbie to mvc and so I am learning how it all works. I have a dynamic nav menu that populates the categories from the db. The menu/categories will populate and work fine when I view the nav page on its own, but it will not work when it is included in the index view page. What should I do to make the dynamic menu view on all the view pages that i need it to? Below is my code, any guidance would be greatly appreciated. Controller: class Behindthescenes extends Controller { public function __construct() { $this->btsModel = $this->model('mBehindthescene'); } public function index() { $data = [ 'title' => 'Admin Dashboard', ]; $this->view('/behindthescenes/index', $data); } // Get categories for nav menu public function bts_cat_nav() { $catnav = $this->btsModel->getCatsNav(); $data = [ 'catnav' => $catnav, ]; $this->view('/includes/bts_cat_nav', $data); } } Model: class mBehindthescene { private $db; public function __construct() { $this->db = new DBC; } // Get Categories for Admin Navigation public function getCatsNav() { $this->db->query('SELECT * FROM categories ORDER BY cat_name ASC'); $result = $this->db->fetchMultiple(); return $result; } } Index View: require_once APPROOT . '/views/includes/header.php'; require_once APPROOT . '/views/includes/bts_nav.php'; require_once APPROOT . '/views/includes/bts_cat_nav.php'; ?> <div class="container-fluid"> ADMIN DASHBOARD </div> Nav Menu View: <div class="container"> <div class="row"> <div class="cat_nav"> <ul> <?php foreach ($data['catnav'] as $cat): ?> <li class="nav-item"><a href="<?php echo $cat->cat_link; ?> class=" nav-link text-white p-1 mb-1 sidebar-link"><i class="<?php echo $cat->cat_fa; ?> text-light fa-lg mr-3"></i><?php echo $cat->cat_name; ?></a></li> <?php endforeach;?> </ul> </div> </div> </div>
I've developed a file upload service of sorts. Think TwitPic, TwitVid and Twaud combined and it's not that far off. I need to determine which content pages are most viewed. Right now I just count each and every page request, so... The problem I run into (of course) is that also agent/bot requests are counted, and for some reason search engines (or other services) are very keen on accessing pages with many pictures on them, so such accesses can easily "overload" and make the access counting quite skewed. Is there a black list of search engine user agents I could deploy, or is there a more generic way of knowing whether I get a request from a search engine rather than a user? I still want the content pages indexed by search engines, so they shouldn't become "invisible" to them, yet I need to be able to determine what accesses are from primarily real users. There's no need to log in to see the content, so I can't use that as a differentiator. I suspect there are also image grabbing agents accessing my pages, and honestly they could be shut out completely. Thanks in advance, Anders I've searched the forum, and haven't yet found what I need. I have a long list of PDF files: http://www.iampeth.com/vintage_magazines.php How can I track the number of downloads for each file? Hello! I want to build a script to basically keep track of the number of hosting accounts that are currently on each server. I have roughly 30 servers (root access, WHM, cPanel) that I would like to be able to track all of from a single page. Could someone help/point me in the right direction/offer any input? thanks! much appreciated! How can I track session requests, so I can, after a certain number of requests (let's say ten because it's physcologically pleasing), have the id regenerated? Hello, I am trying to create article directory for learning PHP MySql and i want to write a script for recording number of views for an article and store it in Database. Can anyone please direct me to a nice simple tutorial or help me with the steps or algorithm? Suppose the link for an article is http://www.domain.com/article.php?id=123 Do i need to put extra variables and create a tracking PHP file for it? |