Edit: after you guys pointed out a DB would work a lot easier, I created one with the following rows:
video_id
video_url
video_title
video_date
video_hits
Now, I don't think that PHP on its own can do an action on click, but my knowledge doesn't go further than html/css/php. Do I need javascript to intercept the click on a certain video to increment the video_hits row in the database?
Would anyone be kind enough to help me to start here?
Thank you.
This is what I started with, no longer valid
I have this code now
<?php
$counts = ("counter.txt");
$hits = file($counts);
$hits[0] ++;
$fp = fopen($counts, "w");
fputs($fp , "$hits[0]");
fclose($fp);
header("Content-type: text/javascript");
echo "document.write('" . $hits[0] . "');";
?>
This works well to show the amount of visitors on a website, but I would like to adapt it so it shows the click on a specific embedded YouTube video.
Is that possible? Thank you.