I recommend using file lock in case you get two visitors at the same time.
You will need to set the counter number to 0 or if you want to cheat you can
$counter = 0;
function Read_Number($counter) {
read the number
}
// increment that number
$counter++;
// log the next hit
function Add_Number($counter) {
open file to file
flock file
print to file
close file
}
not exact code, but defines the basic meaning