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>";
}在这一部分中,不同的$url会在屏幕上显示给用户,用户可以点击任何url来显示数据。我想统计一下哪个url点击了多少次才能给出页面排名??
发布于 2014-12-03 14:39:22
使用中介文件,而不是直接链接到url。
中介PHP文件将计算它被调用的次数(使用计数器),然后重定向到实际的URL
<a href="redirect.php?redirect=http://domain.com>URL</a>根据您的代码,它应该类似于
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>";
}在您的redirect.php文件(计数和重定向文件)中
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']);https://stackoverflow.com/questions/27265024
复制相似问题