Seriously, did I wake up in 1994 today? A page counter? You've posted several times over the years about such things. Again your post seems to be about basic coding problems which aren't language/technology specific, others have already given you the pseudocode you need to implement. Consider installing something like awstats if you are concerned with site usage statistics.