{"id":689,"date":"2020-12-21T16:04:00","date_gmt":"2020-12-21T14:04:00","guid":{"rendered":"https:\/\/html-online.com\/articles\/?p=689"},"modified":"2025-02-04T20:12:55","modified_gmt":"2025-02-04T18:12:55","slug":"simple-php-mysql-visitor-counter","status":"publish","type":"post","link":"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/","title":{"rendered":"Simple Website Visitor Counter With PHP &#038; MySQL"},"content":{"rendered":"<p>In this tutorial I&#8217;m going to describe how to increment a view counter in a MySQL database. We are going to use PHP with the most simple solution. We want to keep this very simple so we won&#8217;t track IP addresses and won&#8217;t use cookies to avoid one visitor being counted multiple times. So basically this will be a page load counter, not an individual user <a href=\"https:\/\/scorecounter.com\/click-counter\/\" target=\"_blank\" rel=\"external nofollow noopener noreferrer\">counter<\/a>.<br \/>\n<img decoding=\"async\" src=\"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2018\/05\/php-mysql-visitor-counter.jpg\" alt=\"php mysql visit counter\" class=\"aligncenter\"><br \/>\n<!--more--><\/p>\n<h2>Prepare the MySQL database tables<\/h2>\n<p>First we have to create the database tables or add the columns to an existing one to store the information.<\/p>\n<p>Connect with <a href=\"https:\/\/www.phpmyadmin.net\/\" target=\"_blank\" rel=\"external nofollow noopener noreferrer\">phpMyadmin<\/a> and open the existing database you want to work with. Click Structure \/ Add 1 column and click Go. Let the column name be &#8216;visits&#8217;, INT type, length 15, Default 0 (so we can start counting from 0). Leave the remaining fields untouched and hit the Save button.<\/p>\n<p>If you don&#8217;t have an existing database, create one with an &#8216;id&#8217; (int, AUTO_INCREMENT, key) field and the &#8216;visits&#8217; mentioned above<\/p>\n<h2>The PHP code<\/h2>\n<p>First we have to connect to the database.<\/p>\n<p>We need two queries. The first one increases the value of the counter, where the id is associated to the specific page. We need to adjust the id for each page, or we can use a PageName\/URL column for that according to our needs:<\/p>\n<p><strong>UPDATE Counter SET visits = visits+1 WHERE id=1<\/strong><\/p>\n<p>The following query retreives the value and stores it in a variable. This will be later displayed in <a href=\"https:\/\/html-css-js.com\/html\/tags\/#body\" target=\"_blank\" rel=\"external nofollow noopener noreferrer\">the HTML body seciton<\/a>.<\/p>\n<p><strong>SELECT visits FROM Counter WHERE id = 1<\/strong><\/p>\n<p>And finally the full code below:<\/p>\n<pre style=\"background:#fff;color:#000\">&lt;?php\n    <span style=\"color:#0206ff;font-style:italic\">$servername<\/span> <span style=\"color:#0100b6;font-weight:700\">=<\/span> <span style=\"color:#d80800\">\"localhost\"<\/span>;\n    <span style=\"color:#0206ff;font-style:italic\">$username<\/span> <span style=\"color:#0100b6;font-weight:700\">=<\/span> <span style=\"color:#d80800\">\"dtbsuser\"<\/span>;\n    <span style=\"color:#0206ff;font-style:italic\">$password<\/span> <span style=\"color:#0100b6;font-weight:700\">=<\/span> <span style=\"color:#d80800\">\"dtbs#passw01\"<\/span>;\n    <span style=\"color:#0206ff;font-style:italic\">$dbname<\/span> <span style=\"color:#0100b6;font-weight:700\">=<\/span> <span style=\"color:#d80800\">\"dtbsname\"<\/span>;\n    <span style=\"color:#0206ff;font-style:italic\">$conn<\/span> <span style=\"color:#0100b6;font-weight:700\">=<\/span> <span style=\"color:#0100b6;font-weight:700\">new<\/span> <span style=\"color:#6d79de;font-weight:700\">mysqli<\/span>(<span style=\"color:#0206ff;font-style:italic\">$servername<\/span>, <span style=\"color:#0206ff;font-style:italic\">$username<\/span>, <span style=\"color:#0206ff;font-style:italic\">$password<\/span>, <span style=\"color:#0206ff;font-style:italic\">$dbname<\/span>);\n\n<span style=\"color:#0100b6;font-weight:700\">    if<\/span> (<span style=\"color:#0206ff;font-style:italic\">$conn<\/span><span style=\"color:#0100b6;font-weight:700\">-&gt;<\/span>connect_error) {\n<span style=\"color:#0100b6;font-weight:700\">        die<\/span>(<span style=\"color:#d80800\">\"Connection failed: \"<\/span> <span style=\"color:#0100b6;font-weight:700\">.<\/span> <span style=\"color:#0206ff;font-style:italic\">$conn<\/span><span style=\"color:#0100b6;font-weight:700\">-&gt;<\/span>connect_error);\n    } \n\n    <span style=\"color:#0206ff;font-style:italic\">$sql<\/span> <span style=\"color:#0100b6;font-weight:700\">=<\/span> <span style=\"color:#d80800\">\"<span style=\"color:#26b31a\"><span style=\"color:#0100b6;font-weight:700\">UPDATE<\/span> Counter <span style=\"color:#0100b6;font-weight:700\">SET<\/span> visits <span style=\"color:#0100b6;font-weight:700\">=<\/span> visits<span style=\"color:#0100b6;font-weight:700\">+<\/span><span style=\"color:#cd0000;font-style:italic\">1<\/span> <span style=\"color:#0100b6;font-weight:700\">WHERE<\/span> id <span style=\"color:#0100b6;font-weight:700\">=<\/span> <span style=\"color:#cd0000;font-style:italic\">1<\/span><\/span>\"<\/span>;\n    <span style=\"color:#0206ff;font-style:italic\">$conn<\/span><span style=\"color:#0100b6;font-weight:700\">-&gt;<\/span>query(<span style=\"color:#0206ff;font-style:italic\">$sql<\/span>);\n\n    <span style=\"color:#0206ff;font-style:italic\">$sql<\/span> <span style=\"color:#0100b6;font-weight:700\">=<\/span> <span style=\"color:#d80800\">\"<span style=\"color:#26b31a\"><span style=\"color:#0100b6;font-weight:700\">SELECT<\/span> visits <span style=\"color:#0100b6;font-weight:700\">FROM<\/span> Counter <span style=\"color:#0100b6;font-weight:700\">WHERE<\/span> id <span style=\"color:#0100b6;font-weight:700\">=<\/span> <span style=\"color:#cd0000;font-style:italic\">1<\/span><\/span>\"<\/span>;\n    <span style=\"color:#0206ff;font-style:italic\">$result<\/span> <span style=\"color:#0100b6;font-weight:700\">=<\/span> <span style=\"color:#0206ff;font-style:italic\">$conn<\/span><span style=\"color:#0100b6;font-weight:700\">-&gt;<\/span>query(<span style=\"color:#0206ff;font-style:italic\">$sql<\/span>);\n\n<span style=\"color:#0100b6;font-weight:700\">    if<\/span> (<span style=\"color:#0206ff;font-style:italic\">$result<\/span><span style=\"color:#0100b6;font-weight:700\">-&gt;<\/span>num_rows <span style=\"color:#0100b6;font-weight:700\">&gt;<\/span> <span style=\"color:#cd0000;font-style:italic\">0<\/span>) {\n<span style=\"color:#0100b6;font-weight:700\">        while<\/span>(<span style=\"color:#0206ff;font-style:italic\">$row<\/span> <span style=\"color:#0100b6;font-weight:700\">=<\/span> <span style=\"color:#0206ff;font-style:italic\">$result<\/span><span style=\"color:#0100b6;font-weight:700\">-&gt;<\/span>fetch_assoc()) {\n            <span style=\"color:#0206ff;font-style:italic\">$visits<\/span> <span style=\"color:#0100b6;font-weight:700\">=<\/span> <span style=\"color:#0206ff;font-style:italic\">$row<\/span>[<span style=\"color:#d80800\">\"visits\"<\/span>];\n        }\n    }<span style=\"color:#0100b6;font-weight:700\"> else<\/span> {\n        <span style=\"color:#3c4c72;font-weight:700\">echo<\/span> <span style=\"color:#d80800\">\"no results\"<\/span>;\n    }\n    \n    <span style=\"color:#0206ff;font-style:italic\">$conn<\/span><span style=\"color:#0100b6;font-weight:700\">-&gt;<\/span>close();\n?&gt;\n\n<span style=\"color:#1c02ff\">&lt;!<span style=\"background:#900;color:#fff\">d<\/span><span style=\"background:#900;color:#fff\">o<\/span><span style=\"background:#900;color:#fff\">c<\/span><span style=\"background:#900;color:#fff\">t<\/span><span style=\"background:#900;color:#fff\">y<\/span><span style=\"background:#900;color:#fff\">p<\/span><span style=\"background:#900;color:#fff\">e <\/span><span style=\"background:#900;color:#fff\">h<\/span><span style=\"background:#900;color:#fff\">t<\/span><span style=\"background:#900;color:#fff\">m<\/span><span style=\"background:#900;color:#fff\">l<\/span>&gt;<\/span>  \n<span style=\"color:#1c02ff\">&lt;<span style=\"font-weight:700\">html<\/span> <span style=\"font-style:italic\">lang<\/span>=<span style=\"color:#d80800\">\"en\"<\/span>&gt;<\/span>\n    <span style=\"color:#1c02ff\">&lt;<span style=\"font-weight:700\">head<\/span>&gt;<\/span>\n        <span style=\"color:#1c02ff\">&lt;<span style=\"font-weight:700\">meta<\/span> <span style=\"font-style:italic\">charset<\/span>=<span style=\"color:#d80800\">\"utf-8\"<\/span>&gt;<\/span>\n        <span style=\"color:#1c02ff\">&lt;<span style=\"font-weight:700\">meta<\/span> <span style=\"font-style:italic\">http-equiv<\/span>=<span style=\"color:#d80800\">\"x-ua-compatible\"<\/span> <span style=\"font-style:italic\">content<\/span>=<span style=\"color:#d80800\">\"ie=edge\"<\/span>&gt;<\/span>\n        <span style=\"color:#1c02ff\">&lt;<span style=\"font-weight:700\">title<\/span>&gt;<\/span>Visit counter<span style=\"color:#1c02ff\">&lt;\/<span style=\"font-weight:700\">title<\/span>&gt;<\/span>\n    <span style=\"color:#1c02ff\">&lt;\/<span style=\"font-weight:700\">head<\/span>&gt;<\/span>\n    <span style=\"color:#1c02ff\">&lt;<span style=\"font-weight:700\">body<\/span>&gt;<\/span>\n        Visits: &lt;?php <span style=\"color:#3c4c72;font-weight:700\">print<\/span> <span style=\"color:#0206ff;font-style:italic\">$visits<\/span>; ?&gt;\n\n    <span style=\"color:#1c02ff\">&lt;\/<span style=\"font-weight:700\">body<\/span>&gt;<\/span>\n<span style=\"color:#1c02ff\">&lt;\/<span style=\"font-weight:700\">html<\/span>&gt;<\/span>\n<\/pre>\n<p>You can <a href=\"\/articles\/category\/css\/\">style<\/a> the widget to match your website. I think a <a href=\"https:\/\/fonts.google.com\/specimen\/Orbitron\" target=\"_blank\" rel=\"external nofollow noopener noreferrer\">7 segment display font<\/a> fits to this counter.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial I&#8217;m going to describe how to increment a view counter in a MySQL database. We are going to use PHP with the most simple solution. We want to keep this very simple so we won&#8217;t track IP addresses and won&#8217;t use cookies to avoid one visitor being counted multiple times. So basically &hellip; <a href=\"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Simple Website Visitor Counter With PHP &#038; MySQL&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,3],"tags":[],"class_list":["post-689","post","type-post","status-publish","format-standard","hentry","category-articles","category-freebies"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Simple Website Visitor Counter With PHP &amp; MySQL<\/title>\n<meta name=\"description\" content=\"In this tutorial I&#039;m going to describe how to increment a view counter in a MySQL database. We are going to use PHP with the most simple\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Simple Website Visitor Counter With PHP &amp; MySQL\" \/>\n<meta property=\"og:description\" content=\"In this tutorial I&#039;m going to describe how to increment a view counter in a MySQL database. We are going to use PHP with the most simple\" \/>\n<meta property=\"og:url\" content=\"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/\" \/>\n<meta property=\"og:site_name\" content=\"HTML Online\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/htmlcoding\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-21T14:04:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-02-04T18:12:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2018\/05\/php-mysql-visitor-counter.jpg\" \/>\n<meta name=\"author\" content=\"HTML Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"HTML Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/\"},\"author\":{\"name\":\"HTML Editor\",\"@id\":\"https:\/\/html-online.com\/articles\/#\/schema\/person\/019f9afa07f209153df0fecfc90b8c1d\"},\"headline\":\"Simple Website Visitor Counter With PHP &#038; MySQL\",\"datePublished\":\"2020-12-21T14:04:00+00:00\",\"dateModified\":\"2025-02-04T18:12:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/\"},\"wordCount\":287,\"publisher\":{\"@id\":\"https:\/\/html-online.com\/articles\/#organization\"},\"image\":{\"@id\":\"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2018\/05\/php-mysql-visitor-counter.jpg\",\"articleSection\":[\"Articles\",\"Freebies\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/\",\"url\":\"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/\",\"name\":\"Simple Website Visitor Counter With PHP & MySQL\",\"isPartOf\":{\"@id\":\"https:\/\/html-online.com\/articles\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2018\/05\/php-mysql-visitor-counter.jpg\",\"datePublished\":\"2020-12-21T14:04:00+00:00\",\"dateModified\":\"2025-02-04T18:12:55+00:00\",\"description\":\"In this tutorial I'm going to describe how to increment a view counter in a MySQL database. We are going to use PHP with the most simple\",\"breadcrumb\":{\"@id\":\"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/#primaryimage\",\"url\":\"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2018\/05\/php-mysql-visitor-counter.jpg\",\"contentUrl\":\"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2018\/05\/php-mysql-visitor-counter.jpg\",\"width\":542,\"height\":241,\"caption\":\"php mysql visit counter\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/html-online.com\/articles\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Simple Website Visitor Counter With PHP &#038; MySQL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/html-online.com\/articles\/#website\",\"url\":\"https:\/\/html-online.com\/articles\/\",\"name\":\"HTML Online Articles\",\"description\":\"Tips, tricks, tutorials\u2026\",\"publisher\":{\"@id\":\"https:\/\/html-online.com\/articles\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/html-online.com\/articles\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/html-online.com\/articles\/#organization\",\"name\":\"HTML Online\",\"url\":\"https:\/\/html-online.com\/articles\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/html-online.com\/articles\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2022\/06\/logo.jpg\",\"contentUrl\":\"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2022\/06\/logo.jpg\",\"width\":350,\"height\":350,\"caption\":\"HTML Online\"},\"image\":{\"@id\":\"https:\/\/html-online.com\/articles\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/htmlcoding\/\",\"https:\/\/www.linkedin.com\/in\/ferencdenes\/\",\"https:\/\/www.youtube.com\/channel\/UCn38Jw1sJzbjVHO95Zp0Sww\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/html-online.com\/articles\/#\/schema\/person\/019f9afa07f209153df0fecfc90b8c1d\",\"name\":\"HTML Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/html-online.com\/articles\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/7c1d8f5e7f1dc3e261766a96ac50c6a907fa5c236e87ab73379c57c9114e92cd?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/7c1d8f5e7f1dc3e261766a96ac50c6a907fa5c236e87ab73379c57c9114e92cd?s=96&d=mm&r=g\",\"caption\":\"HTML Editor\"},\"description\":\"In 2013, while wrestling with a mountain of client articles and an uncooperative CMS, I decided enough was enough. So, I created an online HTML editor purely out of necessity (and mild frustration). What began as a tool for my own sanity quickly evolved into a gift for the world\u2014or at least for anyone trying to avoid breaking their website's code. Since then, I've shared my tech notes on my blog, which serves as both a handy reference and a digital diary of the adventures and misadventures of a coder.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/ferencdenes\/\",\"https:\/\/www.youtube.com\/@htmlg\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Simple Website Visitor Counter With PHP & MySQL","description":"In this tutorial I'm going to describe how to increment a view counter in a MySQL database. We are going to use PHP with the most simple","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/","og_locale":"en_GB","og_type":"article","og_title":"Simple Website Visitor Counter With PHP & MySQL","og_description":"In this tutorial I'm going to describe how to increment a view counter in a MySQL database. We are going to use PHP with the most simple","og_url":"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/","og_site_name":"HTML Online","article_publisher":"https:\/\/www.facebook.com\/htmlcoding\/","article_published_time":"2020-12-21T14:04:00+00:00","article_modified_time":"2025-02-04T18:12:55+00:00","og_image":[{"url":"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2018\/05\/php-mysql-visitor-counter.jpg","type":"","width":"","height":""}],"author":"HTML Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"HTML Editor","Estimated reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/#article","isPartOf":{"@id":"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/"},"author":{"name":"HTML Editor","@id":"https:\/\/html-online.com\/articles\/#\/schema\/person\/019f9afa07f209153df0fecfc90b8c1d"},"headline":"Simple Website Visitor Counter With PHP &#038; MySQL","datePublished":"2020-12-21T14:04:00+00:00","dateModified":"2025-02-04T18:12:55+00:00","mainEntityOfPage":{"@id":"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/"},"wordCount":287,"publisher":{"@id":"https:\/\/html-online.com\/articles\/#organization"},"image":{"@id":"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/#primaryimage"},"thumbnailUrl":"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2018\/05\/php-mysql-visitor-counter.jpg","articleSection":["Articles","Freebies"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/","url":"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/","name":"Simple Website Visitor Counter With PHP & MySQL","isPartOf":{"@id":"https:\/\/html-online.com\/articles\/#website"},"primaryImageOfPage":{"@id":"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/#primaryimage"},"image":{"@id":"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/#primaryimage"},"thumbnailUrl":"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2018\/05\/php-mysql-visitor-counter.jpg","datePublished":"2020-12-21T14:04:00+00:00","dateModified":"2025-02-04T18:12:55+00:00","description":"In this tutorial I'm going to describe how to increment a view counter in a MySQL database. We are going to use PHP with the most simple","breadcrumb":{"@id":"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/#primaryimage","url":"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2018\/05\/php-mysql-visitor-counter.jpg","contentUrl":"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2018\/05\/php-mysql-visitor-counter.jpg","width":542,"height":241,"caption":"php mysql visit counter"},{"@type":"BreadcrumbList","@id":"https:\/\/html-online.com\/articles\/simple-php-mysql-visitor-counter\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/html-online.com\/articles\/"},{"@type":"ListItem","position":2,"name":"Simple Website Visitor Counter With PHP &#038; MySQL"}]},{"@type":"WebSite","@id":"https:\/\/html-online.com\/articles\/#website","url":"https:\/\/html-online.com\/articles\/","name":"HTML Online Articles","description":"Tips, tricks, tutorials\u2026","publisher":{"@id":"https:\/\/html-online.com\/articles\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/html-online.com\/articles\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/html-online.com\/articles\/#organization","name":"HTML Online","url":"https:\/\/html-online.com\/articles\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/html-online.com\/articles\/#\/schema\/logo\/image\/","url":"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2022\/06\/logo.jpg","contentUrl":"https:\/\/html-online.com\/articles\/wp-content\/uploads\/2022\/06\/logo.jpg","width":350,"height":350,"caption":"HTML Online"},"image":{"@id":"https:\/\/html-online.com\/articles\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/htmlcoding\/","https:\/\/www.linkedin.com\/in\/ferencdenes\/","https:\/\/www.youtube.com\/channel\/UCn38Jw1sJzbjVHO95Zp0Sww"]},{"@type":"Person","@id":"https:\/\/html-online.com\/articles\/#\/schema\/person\/019f9afa07f209153df0fecfc90b8c1d","name":"HTML Editor","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/html-online.com\/articles\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/7c1d8f5e7f1dc3e261766a96ac50c6a907fa5c236e87ab73379c57c9114e92cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7c1d8f5e7f1dc3e261766a96ac50c6a907fa5c236e87ab73379c57c9114e92cd?s=96&d=mm&r=g","caption":"HTML Editor"},"description":"In 2013, while wrestling with a mountain of client articles and an uncooperative CMS, I decided enough was enough. So, I created an online HTML editor purely out of necessity (and mild frustration). What began as a tool for my own sanity quickly evolved into a gift for the world\u2014or at least for anyone trying to avoid breaking their website's code. Since then, I've shared my tech notes on my blog, which serves as both a handy reference and a digital diary of the adventures and misadventures of a coder.","sameAs":["https:\/\/www.linkedin.com\/in\/ferencdenes\/","https:\/\/www.youtube.com\/@htmlg"]}]}},"_links":{"self":[{"href":"https:\/\/html-online.com\/articles\/wp-json\/wp\/v2\/posts\/689","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/html-online.com\/articles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/html-online.com\/articles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/html-online.com\/articles\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/html-online.com\/articles\/wp-json\/wp\/v2\/comments?post=689"}],"version-history":[{"count":2,"href":"https:\/\/html-online.com\/articles\/wp-json\/wp\/v2\/posts\/689\/revisions"}],"predecessor-version":[{"id":2218,"href":"https:\/\/html-online.com\/articles\/wp-json\/wp\/v2\/posts\/689\/revisions\/2218"}],"wp:attachment":[{"href":"https:\/\/html-online.com\/articles\/wp-json\/wp\/v2\/media?parent=689"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/html-online.com\/articles\/wp-json\/wp\/v2\/categories?post=689"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/html-online.com\/articles\/wp-json\/wp\/v2\/tags?post=689"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}