Jump to content

Davet

New Members
  • Posts

    3
  • Joined

  • Last visited

Davet's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. <?php $counter_name = 'counter.txt'; file_put_contents($counter_name, date('Y-m-d H:i:s')."\n", FILE_APPEND); // creates file if it doesn't exist // appends if it does exist $k = 0; $clicks = file($counter_name, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); $clicks = array_reverse($clicks); foreach ($clicks as $dt) { ++$k; echo "$k : $dt<br>"; } ?> <script> $("button.counter").on("click", function(e){ e.preventDefault(); $.ajax({ url: 'counter.php', type: 'POST', success: function(counterVal){ } }); }); </script> Dunno.. I got only date...
  2. Thanks Code: <?php $counter_name = 'counter.txt'; file_put_contents($counter_name, date('Y-m-d H:i:s')."\n", FILE_APPEND); $k = 0; foreach (file($counter_name, FILE_IGNORE_NEW_LINES) as $dt) { ++$k; echo "$k : $dt<br>"; } if (!file_exists($counter_name)) { $f = fopen($counter_name, "w"); fwrite($f,"0"); fclose($f); } $f = fopen($counter_name,"r"); $counterVal = fread($f, filesize($counter_name)); fclose($f); $counterVal++; $f = fopen($counter_name, "w"); fwrite($f, $counterVal); fclose($f); echo $counterVal; ?> Date work but counter no: 2021-03-02 14:56:08 2021-03-02 14:57:41 2021-03-02 14:57:42 2021-03-02 14:57:42 2021-03-02 14:57:45 Counter must have first 1) < counter Time not correctly... 5) 2021-03-02 14:56:08 - new must be above like 14:57:45 4)2021-03-02 14:57:41 3) 2021-03-02 14:57:42 2) 2021-03-02 14:57:42 1) 2021-03-02 14:57:45 correctly is 5) 2021-03-02 14:57:45 4) 2021-03-02 14:57:42 3) 2021-03-02 14:57:42 2)2021-03-02 14:57:41 1) 2021-03-02 14:56:08 Very thanks
  3. <?php $counter_name = 'Counter.txt'; if (!file_exists($counter_name)) { $f = fopen($counter_name, "w"); fwrite($f,"0"); fclose($f); } $f = fopen($counter_name,"r"); $counterVal = fread($f, filesize($counter_name)); fclose($f); $counterVal++; $f = fopen($counter_name, "w"); fwrite($f, $counterVal); fclose($f); echo $counterVal; ?> This is click counter... Counter.txt only number... How to add a date? Counter / Date 1. 2021-02-28 19:50:47 2. 2021-02-23 17:57:11 etc
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.