TestNews!简单测试!

插入测试文件:
insert.jsp
<%@page contentType="text/html;charset=gb2312"%>
<%@ include file=
"inc.jsp" %>
<%
String Date= request.getParameter(
"Date");

java.util.Date date=new java.util.Date();
int yyyy=1900+date.getYear();
int mm=date.getMonth()+1;
int dd=date.getDate();
int hh=date.getHours();
int mi=date.getMinutes();
int ss=date.getSeconds();
Date= yyyy+
"-"+mm+"-"+dd+" "+hh+":"+mi+":"+ss;

out.println(Date);

boolean go;
sql=
"insert into news8(title,content,hits,cdate) values ('title','content ','0','"+Date+"')";
out.println(sql);
go = apple.insert(sql);
if(go)
out.println(
"go");
else
out.println(
"Failed.");
apple.closeConn();
%>
显示测试文件:
select.jsp
<%@page contentType=
"text/html;charset=gb2312" %>
<%@ include file=
"inc.jsp" %>
<%
sql=
"select * from news8 order by newsid desc ";
out.println(sql);
out.println(
"<hr>");
rs = apple.select(sql);

while (rs.next()) {
String id = rs.getString(1);
String id1 = rs.getString(2);
String id2 = rs.getString(3);
String id3 = rs.getString(4);
String id4 = rs.getString(5);
String id5 = rs.getString(6);
String id6 = rs.getString(7);
int id7 = rs.getInt(8);
out.println(id);
//out.println(id1);
//out.println(id2);
out.println(id3);
out.println(id4);
out.println(id5);
//out.println(id6);
out.println(
"点击次数");
out.println(
"<a href=addHits.jsp?newsid="+id+"]");
out.println(id7);
out.println(
"[/url]");
out.println(
"<br>");
}
apple.closeConn();
%>
<hr>
增加点击次数文件:
addHits.jsp
<%@page contentType=
"text/html;charset=gb2312"%>
<%@ include file=
"inc.jsp" %>
<%
String newsid=request.getParameter(
"newsid");
boolean go;
sql=
"update news8 set hits=hits+1 where newsid=\'"+newsid+"\'";

go = apple.insert(sql);
if(go)
out.println(
"go");
else
out.println(
"Failed.");
apple.closeConn();
%>

lunzi   2005-01-02 19:55:49 评论:0   阅读:1413   引用:0

发表评论>>

署名发表(评论可管理,不必输入下面的姓名)

姓名:

主题:

内容: 最少15个,最长1000个字符

验证码: (如不清楚,请刷新)

Copyright@2004-2010 powered by YuLog