简体   繁体   中英

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 . 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

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

Home Page - 2nd Record - Page : 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?

Assuming you don't control abc.com, you'll have to make the link go to one of your own pages:

<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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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