Jump to content

Very simple PHP increment, not MYSQL


sean72

Recommended Posts

One of my intranet sites has a very simple, internal order form with a user group of around 50 people.  I have been asked to make the simple PHP order form (which came pre-written but I have customized slightly) generate an automatic order number.

 

I would like to store the number in a simple txt or csv file (or similar), and for each order, load, increment, use and store it again.  It would be ideal if there was some way to lock this file so we didn't get duplicates, but the likelihood of two users making an order at the same time are very low.  I would need to insert this code segment or routine in the existing PHP file.

 

I studied programming, so I understand the concepts, but do not know the syntax for PHP very well.  Code suggestions should be complete please.

 

Thank you!

 

Link to comment
https://forums.phpfreaks.com/topic/101894-very-simple-php-increment-not-mysql/
Share on other sites

Found a simple counter in this forum under tutorials

//This is the code for the counter it makes a txt file named counter and it stores
// the amount of times its been viewed
$TextFile = "counter.txt";
$Count = 0+trim(file_get_contents($TextFile));
$Count++;
file_put_contents($TextFile,$Count);

 

very simple, and to the point :)

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.