To make a link counter, first create a table that has these fields:
page name: char
number of hits: int
most recent update: date
Then on each page that should be tracked, write a query that selects the current number of hits for that page, increases it by one, and writes the new number like this:
$query = "select number_hits from counter where page='index.html'";
Then find number_hits
Then increase the number_hits like this:
$number_hits++;
Then write that number (along with the current time) to the table like this:
$query = "update counter set number_hits=$number_hits,recent_update=now() where page_name='index.html'";
To see the top 100 most visited pages, do this:
$query = "select page_name from counter order by number_hits desc limit 100";
And to see the 20 most recent updates, do the same thing like this:
$query = "select page_name from counter order by recent_update desc limit 20";