PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
How would I make a view counter that:
1. Writes to a text file.
2. Adds 1 to the existing number and rewrites it in to the file.
3. Make a new line with a new number for each day.
I do not understand part three. Please clarify, and explain the purpose.
I want a new line for each day.
Example:
The code writes 67 views to the file for 9/8 and there were no more views on 9/8 then some one views the page with this script on it on 9/9.
I want the file or a different script to be activate to make a new line and add 1.
Basically I want a script that would make a new line in the text file and write a 0 each day.
I see, you want separate lines for different days, each with the number of hits that day. You really shouldn't do that with a text file, because of the issues that arise when the file is accessed multiple times within the same moment (as tasairis stated), and because of performance.
Use a SQL query to check if there is a row for that day. If there is, add one to the `count` column (or whatever). If there isn't, make one and give `count` a value of 1.