Since web browsers don't keep persistently-open connections to web servers (they just say "gimme the file and i'll leave you alone"), this really isn't possible.
If you wanted to get fancy, you could track a user's movement within your site. You could use 2 cookies, one to track the last file they visited and one to track the timestamp of the hit.
Something like $lastpage = "/index.php" and $lasthit = "[time() here]". At the top of each page have it run a quick function to update your database which would subtract 1 from $lastpage's count, and add 1 to whatever new page they're on now's count.
Naturally this would only work as long as they're surfing around your site. It wouldn't be a bother if they entered your site from an outside source (just +1 to that file's count and set the cookies), but if they close their browser or follow an outside link, their connection to the current file's count would be lingering in your database, which would be bad. So you'd have to setup some kind of time-out method for updating the database after X minutes (hence the need for the $lasthit cookie).
Wow that post was longer than I had planned. Good luck 🙂
--Ryan