如何计算用户点击的URL? [重复]

This question already has an answer here:

while($rows=mysql_fetch_assoc($run)) {

      $title=$rows['title'];
      $desc=$rows['description'];
      $url=$rows['url'];
      //include 'index.php';
      echo "<a href='$url'><b>$title</b></a><br><a href='$url'>$url"</a><p>";
      }

In this part different $url will be shown in the screen to the user and user can click any url to show the data.I want to count which url clicked how many times to give the page ranking??

</div>

Use a mediator file instead of directly linking to the url

The mediator PHP file will count how many times it has been called (use a counter there) and then redirect to the actual URL

<a href="redirect.php?redirect=http://domain.com>URL</a>

As per your code, it should be something like

while($rows=mysql_fetch_assoc($run)) {

  $title=$rows['title'];
  $desc=$rows['description'];
  $url=urlencode($rows['url']);
  //include 'index.php';
  echo "<a href='redirect.php?$url'><b>$title</b></a><br><a href='$url'>$url"</a><p>";
  }

And in your redirect.php file (count and redirect file)

if(!file_exists('counter.txt')){ 
  file_put_contents('counter.txt', '0');
}
file_put_contents('counter.txt', ((int) file_get_contents('counter.txt')) + 1);
header('Location: ' . $_GET['redirect']);