PHP - Average Views Per Hour
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!
Similar TutorialsOk 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
Sir, { "DiplomaFirstYear": { "2016-2017.1": 3.88, "2016-2017.2": 4, "2016-2017.3": 3.3 }, "DiplomaSecondYear": { "2016-2017.3": 4, "2017-2018.1": 3.88, "2017-2018.2": 3.94, "2017-2018.3": 3.3 }, "AdvancedDiploma": { "2017-2018.3": 4, "2018-2019.1": 3.74, "2018-2019.2": 3.62 }, "Bachelor": { "2018-2019.3": 3.15 } }
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. I can't remember the math to do this, but I use MySQL to calculate an average: 5 = 100% 0 = 0% I want to make a bar that shows an average (like a bar graph) so lets say I get 2.5 as one of my returned results, that means the bar should only be 50% long of the maximum width. Using calculations, how can I get the number 50 (the max width is 100% of a table cell)? Hi. Im trying to make a PHP code that will find the average number. What I want is, a lot of input fields where you can write a number in. Then my code should take these numbers and divide them with the amount of input fields that has been written in. So that some fields you don't have to write a number, and the code will still give you a correct average. My code so far: Code: [Select] <?php if (isset($_POST['calc'])) { $m=$_POST['mat']; $e=$_POST['da']; $s=$_POST['eng']; $f=$_POST['fys']; $h=$_POST['bio']; $p=$_POST['geo']; $ave=($m+$e+$s+$f+$h+$p)/; } ?> <a href="" onclick="return hs.htmlExpand(this, { headingText: 'Beregn dit Gennemsnit:' })"> <b>Beregn dit Gennemsnit: <?php echo $ave;?></b><br></br> </a> <div class="highslide-maincontent"> <form id="gennemsnit" name="form1" method="post" action=""> Matematik<input name="math" type="text" id="mat" size="3" maxlength="4" /><br /> Dansk<input name="eng" type="text" id="da" size="3" maxlength="4" /><br /> Engelsk<input name="sci" type="text" id="eng" size="3" maxlength="4" /><br /> Fysik<input name="fil" type="text" id="fys" size="3" maxlength="4" /><br /> Biologi<input name="he" type="text" id="bio" size="3" maxlength="4" /><br /> Geografi<input name="pe" type="text" id="geo" size="3" maxlength="4" /></td><br /> <input name="calc" type="submit" id="calc" value="Beregn"/><br /><br /> </form> What I need is the code of how to divide with the amount of input fields that has been written in. thanks for any help If you had a function that calculated the average of a fixed quantity of numbers, what type of scope issues would you anticipate? Nice forum here. I know nothing about PHP and need some help. Here is the deal. Members on a forum will be rating products. There will be 4 (this number could change) fields where they will select a number from a drop down menu to rate different characteristics of the product. I need to average those numbers for the overall rating. The code that outputs the individual numbers selected looks like this: {$data['record']['field_14']} 14 being one of the fields, and 15, etc. So what I need is code that takes multiple fields and outputs the average number. I appreciate any help! And please keep in mind I am not familiar with PHP coding, so if you could be as detailed as possible I would appreciate it. Thanks! 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.... Hi, Firstly, these are my tables: CLASS class_id class_name 1 Donkeys 2 Monkeys 4 Classic 9 Humans COURSES class_id courses_number 9 6 9 2 1 3 2 2 I would like to print average course_number for each class_name. So for class_name Donkeys would have average course_number 3. And for clasS_name Humans, average course_number is 4. Do you get my point? If anybody could give me code for that gets site views, that would be really nice. Could someone please advise the best way to determine the average of a DATE field in a SELECT query?
Hi, I'm trying to get out the average of records stored in a mysql table This is the code im using right now Code: [Select] mysql_query("SELECT DATE(dato) , COUNT( dato ) AS counted FROM dekodere GROUP BY date(dato)", $link); $ave = mysql_num_rows($ave); This is getting out the average, but i need to exclude weekends because there is not stored anything during the weekend so it's making the average go off.. any tips? 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 hi all! i have 2 tables: PRODUCTS id_prod, id_cat, date, prod_name CATEGORIES id_cat, cat_name My goal is obtain the average (day and month) of all products inserted by users in this format: category Hardwa avg daily 20, month 100 category Components: avg daily 2, month 15 and so on. PS: the 'date' field is unix timestamp (int 10). Can you help me? I am trying to display date and time below code display date correctly but when it come to display time it display 3 hour behind. eg. when it is 12:47 PM in my system it display 9:47 PM Code: [Select] <?php $todaydate=date("j - F - Y g:i:s a"); echo $todaydate; ?> Hi, i'm trying to create some detailed statistics about customer activity, i have entries in my mysql db when the customer has been active for the last time and want to create some statistics about that, basically a "online last 24 hours" but from specific countries. Now i've tried this: Code: [Select] $time = date('Y-m-d H:i:s'); $time24 = date("Y-m-d H:i:s", time()-((60*60)*24)); $query = "SELECT COUNT(*) as Anzahl FROM customers WHERE country = 'de' AND time BETWEEN '$time' AND '$time24' "; to get the current date and select all customers that have been available from the current date minus 24 hours, what's my mistake here, as this doesn't seem to work! Thanks $time="19:00:00"; how to do i output one hour later from the variable above? |