Jump to content

multiple single click counters


shugs

Recommended Posts

Hi all,

 

slightly confusing title!

 

What I am trying to do is make a simple stores system whereby I can add and remove stores.

 

It is purely php and no mySQL.

 

My idea was to create a text file with the individual number and then include the file on the table on the page.

 

I have worked out how to increment one value by one, but the others I am struggling with.

 

Example I wish to have two links one which I click to increase and another to decrease the value by one. 

 

It's the multiple issue that is confusing me, I create a txt file and a php file using a variable from a submitted form (part number).  The php file holds info and the text file holds the number which is default at '0' (Zero).

 

My idea was to write some php to the file, perhaps when I click the plus it will open and write to the file + 1 ..

 

Any guidance or points in the right direction would be greatly appreciated.  Thanks.

 

Shugs

Link to comment
https://forums.phpfreaks.com/topic/221007-multiple-single-click-counters/
Share on other sites

Updating the value is easy:

 

// Get the current value and cast as an integer
$counter = (int) file_get_contents('./counter.txt');

// Set the new value
$counter++;

// Store in file (overwrites current contents)
file_put_contents('./counter.txt', $counter);

 

It's the multiple issue that is confusing me

..  Not sure what you mean by this though?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.