Jump to content

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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