简体   繁体   English

PHP - DYNAMIC PAGE计数器增量

[英]PHP - DYNAMIC PAGE counter increment

I have a dynamic page , which fetch data from database . 我有一个动态页面,从数据库中获取数据。 Say for eg there are 2 record which is generated depending on query . 比如说,根据查询生成2条记录。 So what i want to do is when some one click the Home link on 1st record , it should go to next page and over there php code is there which will increment the counter that is how many times the page is visted 所以我想做的是当有人点击第一条记录上的Home链接时,它应该转到下一页并且那里有PHP代码,这将增加计数器,即页面被访问的次数

Similarly when 2nd record Home link is clicked it should go to some page and then again again counter for that page is incremented 类似地,当单击第二个记录主页链接时,它应该转到某个页面,然后再次对该页面的计数器递增

so say eg 所以说,例如

Home Page - 1st Record - Page : http://www.abc.com/Wakad-T4248349 主页 - 第1条记录 - 页面: http//www.abc.com/Wakad-T4248349

Home Page - 2nd Record - Page : http://www.abc.com/Himn-T3333333 主页 - 第2条记录 - 页: http//www.abc.com/Himn-T3333333

Or another way of doing this , please help 或者另外一种方法,请帮忙

<div id="menubar">
  <ul>
    <li class="current_page_item">
      <a href="count.php" name="abc<?php $i; ?>">Home</a>
      <?php $_SESSION['Home']=$row['ID']; echo $_SESSION['Home'];?>
    </li>
  </ul>
</div>


<div id="menubar">
  <ul>
    <li class="current_page_item">
      <a href="count.php" name="abc<?php $i; ?>">Home</a>
      <?php $_SESSION['Home']=$row['ID']; echo $_SESSION['Home'];?>
    </li>
  </ul>
</div>

Why not just have a field in the database which keeps track of how many times that particular page has been fetched? 为什么不在数据库中有一个字段来跟踪特定页面被提取的次数? Or are you looking for unique IPs? 或者您在寻找独特的IP?

Assuming you don't control abc.com, you'll have to make the link go to one of your own pages: 假设您不控制abc.com,您必须将链接转到您自己的某个页面:

<a href="redirect.php?link=abc.com/Wakad-T4248349"> ...

and on redirect.php, increase your counter (which you'll probably want to store in a DB...) and redirect them to the page. 并在redirect.php上,增加你的计数器(你可能想要存储在数据库中......)并将它们重定向到页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM