{"id":3712,"date":"2013-08-14T09:17:19","date_gmt":"2013-08-13T23:17:19","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=3712"},"modified":"2020-06-24T12:50:57","modified_gmt":"2020-06-24T02:50:57","slug":"phpjavascripthtml-hit-counter-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/phpjavascripthtml-hit-counter-primer-tutorial\/","title":{"rendered":"PHP\/Javascript\/HTML Hit Counter Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/HitCounter\/\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"PHP\/Javascript\/HTML Hit Counter Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/HitCounter\/HitCounter.jpg\" title=\"PHP\/Javascript\/HTML Hit Counter Primer Tutorial\"   \/><\/a><p class=\"wp-caption-text\">PHP\/Javascript\/HTML Hit Counter Primer Tutorial<\/p><\/div>\n<p>Here is a tutorial that shows a way to create a very rudimentary PHP <a target=_blank title='hit explained by Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/Hit_%28internet%29'>Hit<\/a> Counter for a particular webpage.   By &#8220;for a particular webpage&#8221; mean that to get a meaningful hit count for a website you probably are best placed to use a statistics package from your web provider or use a tool that the web provider gives you.<\/p>\n<p>Link to some downloadable PHP programming code &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/PHP\/HitCounter\/includeoncehc.php_GETME' title='Download me'>includeoncehc.php<\/a>.<\/p>\n<p>Link to some downloadable PHP programming code &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/PHP\/HitCounter\/useofhc.php_GETME' title='Download me'>useofhc.php<\/a>.<\/p>\n<p>For this tutorial there is some flexibility in regards to what type of HTML element you use to display your Hit Count statistics.   The code handles HTML elements with either\/both Javascript DOM concepts of <em>innerHTML<\/em> and\/or <em>value<\/em>.  There is flexibility regarding your wording around the 0 (zero) of the HTML h1 element used in useofhc.php too, as long as 0 (zero), or other numbers for that matter,  do not appear in your reworked <a target=_blank title='was hoping, and yes, it is true!' href='http:\/\/www.thefreedictionary.com\/prefixal'>prefixial<\/a> wording.<\/p>\n<p>You&#8217;ll see <em>&lt;meta name=&#8221;viewport&#8221; content=&#8221;width=device-width, initial-scale=1.0&#8243;&gt;<\/em> in the code for useofhc.php within <em>&lt;head&gt;<\/em> and <em>&lt;\/head&gt;<\/em> which is code used to make websites user-friendly to mobile phones (and maybe have a look at some of the links of using <a target=_blank title='viewport meta tag ideas' href='https:\/\/www.google.com.au\/search?q=%22viewport+meta+tag%22+%22mobile+phone%22&#038;ie=utf-8&#038;oe=utf-8&#038;rls=org.mozilla:en-US:official&#038;client=firefox-a&#038;gws_rd=cr'>this<\/a>).  Another approach to mobile phone friendly code is to express width values as percentage values, and you&#8217;ll see that principle being applied in useofhc.php also.   You don&#8217;t have PHP?   You could use a Javascript Cookie approach?   (<a target=_blank title='Javascript Cookie Hit Counter' href='https:\/\/www.google.com.au\/search?q=%22Javascript+cookie+hit+counter%22&#038;ie=utf-8&#038;oe=utf-8&#038;rls=org.mozilla:en-US:official&#038;client=firefox-a&#038;gws_rd=cr'>here<\/a>? &#8230; or run tutorial, go View->Page Source with your web browser to get some starting ideas)<\/p>\n<p>A PHP topic of interest that comes into play regarding this tutorial is the use of <em>require_once()<\/em> and\/versus <em>include_once()<\/em> so take a look at <a target=_blank title='require_once' href='http:\/\/php.net\/manual\/en\/function.require-once.php'>require_once information<\/a> and <a target=_blank title='include_once' href='http:\/\/php.net\/manual\/en\/function.include-once.php'>include_once information<\/a>.  You can actually do this job with one PHP where you plugin the contents of includeoncehc.php in place of the <em>require_once()<\/em> call, and you may want to try this.   My apologies for the file naming confusion where includeoncehc.php is actually used with a <em>require_once()<\/em> call &#8230; but, c&#8217;est la vie.<\/p>\n<p>You might be interested in blinking text, and this is achieved with this tutorial, by the use of <em>&lt;blink&gt;<\/em> and <em>&lt;\/blink&gt;<\/em>.<\/p>\n<p>So enjoy this live run <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/HitCounter\/\" title='PHP\/Javascript\/HTML Hit Counter Primer Tutorial'>here<\/a>.<\/p>\n<p><strong><em>Did you know?<\/em><\/strong><\/p>\n<p>You may notice that the word Javascript does not appear within the code of <em>useofhc.php<\/em> nor <em>includeoncehc.php<\/em> as above, so you may wonder how it can be claimed to involve Javascript.   The reason is that Javascript is the default language of the <em>&lt;script&gt; &lt;\/script&gt;<\/em> notation, as used in this tutorial, where the PHP writes its own &#8220;Javascript&#8221; (by implication), and is the default language of HTML element event code as well, so, just as you can have <br \/><em>&lt;a href=&#8221;<a target=_blank title='Two Ronnies' href='http:\/\/www.youtube.com\/watch?v=h-mX9T2qyIQ#zkWMcRlE1mQ'>http:\/\/www.youtube.com\/watch?v=h-mX9T2qyIQ#zkWMcRlE1mQ<\/a>&#8221; onclick=&#8221;alert(&#8216;FUNEX?&#8217;);'&#8221; title=&#8221;Two Ronnies Question&#8221;&gt;FUNEX?&lt;\/a&gt;<\/em> <br \/>you can just as well use syntax like <br \/><em>&lt;a href=&#8221;<a target=_blank title='Two Ronnies' href='http:\/\/www.youtube.com\/watch?v=h-mX9T2qyIQ#zkWMcRlE1mQ'>http:\/\/www.youtube.com\/watch?v=h-mX9T2qyIQ#zkWMcRlE1mQ<\/a>&#8221; onclick=&#8221;Javascript: alert(&#8216;S,VFX&#8217;);'&#8221; title=&#8221;Two Ronnies Answer&#8221;&gt;S,VFX&lt;\/a&gt; <\/em>\n<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d3712' onclick='var dv=document.getElementById(\"d3712\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?s=Google+Chart#content\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d3712' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Here is a tutorial that shows a way to create a very rudimentary PHP Hit Counter for a particular webpage. By &#8220;for a particular webpage&#8221; mean that to get a meaningful hit count for a website you probably are best &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/phpjavascripthtml-hit-counter-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,37],"tags":[327,567,576,652,932,997,1319],"class_list":["post-3712","post","type-post","status-publish","format-standard","hentry","category-elearning","category-tutorials","tag-did-you-know","tag-hit-counter","tag-html","tag-javascript","tag-php","tag-programming","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/3712"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=3712"}],"version-history":[{"count":1,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/3712\/revisions"}],"predecessor-version":[{"id":49451,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/3712\/revisions\/49451"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=3712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=3712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=3712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}