统计某一篇新闻的阅读次数
比如我在数据库中用“CS”这个字段来记录访问次数

解决方案 »

  1.   

    update tabe1 set cs = cs+1 where id = argid
      

  2.   

    还是不行啊
    就是这个页面大家帮我看看
    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
    <% request.setCharacterEncoding("gb2312"); %>
    <%@ include file="include/conn.jsp"%>
    <%! String id=""; %>
     <% 
     id=request.getParameter("x");
    String sql="select * from xwfb where id="+id; 
    ResultSet rs=stmt.executeQuery(sql); 
    rs.next();
    String bt=rs.getString("bt");
    String sj=rs.getString("sj");
    String zz=rs.getString("zz");
    String ly=rs.getString("ly");
    String cs=rs.getString("cs");
    String content=rs.getString("content");
    %><html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title><%= bt %></title>
    <style type="text/css">
    <!--
    body,td,th {
    font-size: 9pt;
    }
    body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    background-image: url(top.files/kaoshi.jxrenshi.gov.files/bks.gif);
    }
    a:link {
    color: #000000;
    text-decoration: none;
    }
    a:visited {
    text-decoration: none;
    color: #000000;
    }
    a:hover {
    text-decoration: none;
    color: #CC6600;
    }
    a:active {
    text-decoration: none;
    }
    -->
    </style><script language=javascript>
    function ContentSize(size)
    {
    var obj=document.all.ContentBody;
    obj.style.fontSize=size+"px";
    }
    </script></head>
    <link href="../admin/css.css" rel="stylesheet" type="text/css">
    <body bgcolor=#FFFFFF text=#000000>
      <table width="778" border="0" align="center" cellspacing="0" bgcolor="#FFCC66">
      <TR>
        <TD colSpan=4><IMG height=18 src="top.files/kaoshi.jxrenshi.gov.files/top_1.gif" 
          width=778></TD>
      </TR>
      <tr>
        <td height="145"><div align="right">
          <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="778" height="150">
            <param name="movie" value="flash/index.swf">
            <param name="quality" value="high">
            <embed src="flash/index.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="778" height="150"></embed>
          </object>
        </div></td>
      </tr><tr>
        <td height="27" background="top.files/kaoshi.jxrenshi.gov.files/x.gif"><img src="top.files/kaoshi.jxrenshi.gov.files/jiantou.gif" width="11" height="9">您现在的位置:<a href="http://www.jxrenshi.gov.cn">首页</a>&gt;&gt;&gt;<a href="index.jsp">三支一扶专栏</a>&gt;&gt;&gt;<%= bt %></td>
      </tr>
      <tr><td height=1 bgcolor=#999999 colspan=2></td></tr>
    </table><table width=778 align="center" cellpadding=0 cellspacing=0 bgcolor="#FFFFFF">
    <tr><td height=1 bgcolor=#999999 colspan=2></td></tr><tr><td height=4 colspan=2 bgcolor=#EEEEEE></td></tr><tr><td width=AvailWidth align=center valign=top>
    <table width=96% cellspacing=0 cellpadding=5>
      <tr><td height=30 align=center style="font-size:16px;font-weight:bold;filter:DropShadow(Color=#cccccc, OffX=1, OffY=1, Positive=1)"><%= bt %></td>
      </tr>
    <tr>
      <td align=center>字体<a href="javascript:ContentSize(16)">:</a>【<a href="javascript:ContentSize(16)">大</a><a href="javascript:ContentSize(14)">&nbsp;中</a><a href="javascript:ContentSize(12)">&nbsp;小</a>】 发布时间:<%= sj %> 来源:<%= ly %> 作者:<%= zz %>   阅读<font color="#FF0000"><%= cs %></font>次</td>
    </tr>
    <tr valign="top">
      <td height="452">  <span id="ContentBody" style="display:block;padding:10px 10px"><%= content %></span></td>
    </tr><%
     rs.close();
     stmt.close();
    conn.close(); %>
    <tr><td><script language="javascript" src="../admin/about.asp?id={about}"></script></td></tr>
    <tr><td height="22" align=center>【<a href='javascript:window.close();'>关闭窗口</a>】</td>
    </tr></table></td>
    </tr></table><TABLE width=778 align=center cellspacing="0" background=kaoshi.jxrenshi.gov.files/foot.jpg>
      <TBODY>
      <TR>
        <TD height=107 background="top.files/kaoshi.jxrenshi.gov.files/foot.jpg">
          <DIV align=center><BR><BR><BR><BR>江西省人事厅主办 <BR>江西省人事厅信息规划处承办 
          <BR>Copyright&copy; 2003-2005 www.jxrenshi.gov.cn,All Rights Reserved 
          <BR>ICP备案号: 赣 <A href="http://www.miibeian.gov.cn/">B2-20050415</A> 号 
    <BR></DIV></TD></TR></TBODY></TABLE>
    </body></html>