php+js 如何获取超链接被点击的次数。。在线等啊,高手请赐教

解决方案 »

  1.   

    onClick一下就加1,然后post给PHP存起来。
      

  2.   

    文章 hits 加 1.
      

  3.   

    1 onclick后post给php
    2 也可以做个中间页面 先迁移到中间页面 在中页面+1 +完之后跳转到你要去的页面
      

  4.   


    可不可以 再详细点啊
    我的超链接 已经在循环里了while ($row=mysql_fetch_row($result))
    {
    ?>

      <li><a href="inside.php?ctid=<?php echo $row[0];?>"><?php echo mb_substr($row[2],0,15,'utf-8'); ?></a></li>

    <?php
       }

    // 释放资源
    mysql_free_result($result);
    // 关闭连接
    //mysql_close();  

      

  5.   

    对帖子的数据库增加键值,每onclick,就往增加值1
      

  6.   

    我知道 是加加 这都没有 可问题 js怎么与php结合起来 把数据存到数据里 才是正题啊
    有没有源码 参考参考啊
    谢谢。
      

  7.   

    PHP和JavaScript交互的例子,摘自http://www.w3schools.com/php/php_ajax_php.asp<html>
    <head>
    <script type="text/javascript">
    function showHint(str)
    {
    if (str.length==0)
      {
      document.getElementById("txtHint").innerHTML="";
      return;
      }
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
        }
      }
    xmlhttp.open("GET","gethint.php?q="+str,true);
    xmlhttp.send();
    }
    </script>
    </head
    <body><p><b>Start typing a name in the input field below:</b></p>
    <form>
    First name: <input type="text" onkeyup="showHint(this.value)" size="20" />
    </form>
    <p>Suggestions: <span id="txtHint"></span></p></body>
    </html>
      

  8.   

    下面的是gethint.php文件
    <?php
    // Fill up array with names
    $a[]="Anna";
    $a[]="Brittany";
    $a[]="Cinderella";
    $a[]="Diana";
    $a[]="Eva";
    $a[]="Fiona";
    $a[]="Gunda";
    $a[]="Hege";
    $a[]="Inga";
    $a[]="Johanna";
    $a[]="Kitty";
    $a[]="Linda";
    $a[]="Nina";
    $a[]="Ophelia";
    $a[]="Petunia";
    $a[]="Amanda";
    $a[]="Raquel";
    $a[]="Cindy";
    $a[]="Doris";
    $a[]="Eve";
    $a[]="Evita";
    $a[]="Sunniva";
    $a[]="Tove";
    $a[]="Unni";
    $a[]="Violet";
    $a[]="Liza";
    $a[]="Elizabeth";
    $a[]="Ellen";
    $a[]="Wenche";
    $a[]="Vicky";//get the q parameter from URL
    $q=$_GET["q"];//lookup all hints from array if length of q>0
    if (strlen($q) > 0)
      {
      $hint="";
      for($i=0; $i<count($a); $i++)
        {
        if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q))))
          {
          if ($hint=="")
            {
            $hint=$a[$i];
            }
          else
            {
            $hint=$hint." , ".$a[$i];
            }
          }
        }
      }// Set output to "no suggestion" if no hint were found
    // or to the correct values
    if ($hint == "")
      {
      $response="no suggestion";
      }
    else
      {
      $response=$hint;
      }//output the response
    echo $response;
    ?>
      

  9.   

    浏览器端获取事件,定义一个变量值为1,或者添加一个控件,保存该值,然后post到php,在php端获取该值并保存到数据库!
      

  10.   


    jQuery(document).ready(function(){
    $('a').click(function(){
    $.ajax({
       type: "POST",
       url: "click.php",
       data: "href="+$(this).attr('href')+"&rel="+$(this).attr('rel'),//还可以根据情况自定义属性,用于区分
       success: function(msg){
     //
       }
    });
    }); 
    });
      

  11.   

    不用js也行啊<a href="hit.php?http://www.csdn.net"></a>
    //hit.php
    <?php
    //这里记录 + 1
    header('location:http://www.csdn.net');
    ?>