如何实现在同一页面既查询有能插入?

王释之 2000-03-26 04:22:00
我想编写一页像本论坛回复一样的页面。
即时输入能即时反映出来。
谢谢!
...全文
127 4 打赏 收藏 举报
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
蝈蝈俊 2000-03-26
出现过那种问题???
给我寄一个数据库.
  • 打赏
  • 举报
回复
王释之 2000-03-26
king.ghj1976两位好!
我有一段程序,希望您们改正!

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title></title>
</head>

<body link="#008080" vlink="#c0c0c0">
<%
Set Conn=Server.CreateObject("ADODB.Connection")
Connstr="DBQ="+server.mappath("../bbs.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;ImplicitCommitSync=Yes;MaxBufferSize=512;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;Threads=3;UserCommitSync=Yes;"
Conn.Open connstr
%>
。。。。。。。。无用页面html..........
<%
sql="SELECT * FROM bbs where num='"& Request.QueryString &"'"
dim rootRs
Set rootRs=Server.CreateObject("ADODB.RecordSet")
rootRs.Open sql,conn,1,1
if not rootRs.EOF or rootRs.BOF then
set topic=rootrs("topic")
set name=rootrs("name")
set shijian=rootrs("timet")
set count=rootrs("write")
set subject=rootrs("subject")
set content=rootrs("content")
' content=replace(content,chr(10)&chr(13),<br>)
%>
<p align="left">
<IMG border=0 height=15 src="../tu.gif" width=580></P>
<p style="margin-bottom: -10" align="left">    <font size="2">
<b>主    题:</b></font><%=topic%></p>
<p style="margin-bottom: -10" align="left"><b><font size="2">    
作    者:</font></b><%=name%></p>
<p style="margin-bottom: -10" align="left"><b><font size="2">      
所属科目:</font><%=subject%></b></p>
<p style="margin-bottom: -6" align="left"><b><font size="2">    
回复次数:</font></b><%=count%></p>
<p style="margin-bottom: -6" align="left"><b><font size="2">    
问题人气:</font></b><%=20*count%></p>
<p style="margin-bottom: -6" align="left"><b><font size="2">    
发表时间:</font></b><%=shijian%></p>
<p style="margin-bottom: -6" align="left"> </p>
<p style="margin-bottom: -6" align="left"><font size="2">    
<%=content%></font></p>
<p style="margin-bottom: -6" align="left"><b><font size="2">    
回复纪录:</font></b></p>
<p style="margin-bottom: -6"><b>  </b></p>
<table border="0" width="92%">
<tr bgcolor="#f8ac50">
<td width="55%"><STRONG><FONT size=2
style="BACKGROUND-COLOR: #f8ac50">问题标题</FONT></STRONG></td>
<td width="15%">
<p align="left"><STRONG><FONT size=2
style="BACKGROUND-COLOR: #f8ac50">回复人</FONT></STRONG></p> </td>
<td width="30%">
<p align="left"><FONT size=2
style="BACKGROUND-COLOR: #f8ac50"><STRONG>回复时间</STRONG></FONT></p></td>
</tr>
<%
if rootrs("xunxu")=1 then
Do While Not rootRs.Eof AND RowCount>0%>
<tr bgcolor="#cccccc">
<td width="55%"><FONT size=2
style="BACKGROUND-COLOR: #cccccc"><%=topic%></FONT></td>
<td width="15%">
<p align="left"><FONT size=2
style="BACKGROUND-COLOR: #cccccc"><%=name%></FONT></p> </td>
<td width="30%">
<p align="left"><FONT size=2
style="BACKGROUND-COLOR: #cccccc"><%=shijian%></FONT></p></td>
</tr>
<tr bgcolor="#cccccc">
<td width="80%"><p align="left"><FONT size=2
style="BACKGROUND-COLOR: #cccccc"><%=content%></FONT></p></td>
</tr>

<%rootRs.MoveNext
RowCount=RowCount-1
%>
</table>
<p style="margin-bottom: -10" align="left">      
<form name=topic method=post action="topic.asp?<%=Request.QueryString%>" target="_self">
<b><font size="2">我要回复</font></b></p>
<hr>
<p align="left">    <INPUT type="text" id=text1 name=htopic size="37" value="Re:<%=topic%>"> <INPUT type="checkbox" id=checkbox1 name=checkbox1 checked>有人参与讨论这个问题,请用EMail通知我</p>
<p align="left">    <TEXTAREA rows=9 cols=57 id=textarea1 name=hcontent></TEXTAREA></p>
<p align="left"><input type="hidden" name="rewordnum" value="1"></p>
<p align="left">    <INPUT type="submit" value="回复" id=submit1 name=b1></p>
</form>
<%
end if
end if
rootRs.close
Set rootRs=nothing
conn.close
Set conn=nothing
%>
<%
Set Conn=Server.CreateObject("ADODB.Connection")
Connstr="DBQ="+server.mappath("../bbs.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;ImplicitCommitSync=Yes;MaxBufferSize=512;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;Threads=3;UserCommitSync=Yes;"
Conn.Open connstr

b1=Request.Form("b1")
if b1="回复" then
sz = "'" &application("name") &_
"', '"& application("mail") &_
"', '"& Request.Form("htopic") &_
"', '"& subject &_
"', '"& Request.Form("hcontent") &_
"','"& Request.Form("rewordnum") &_
"','"& Request.QueryString &_
"','"& Request.ServerVariables("Remote_Addr") &"',date()+time()"
into_db = "INSERT INTO bbs (name,mail,topic,subject,content,xunxu,num,ip,time) VALUES(" &_
sz & ")"
Conn.Execute(into_db)



conn.close
Set conn=nothing
end if
%>
</td>
</tr>

</table>
</body>
</html>
  • 打赏
  • 举报
回复
蝈蝈俊 2000-03-26
给您一段程序参考:
<script language="javascript">
<!--
function del()
{
if (confirm("您确认删除这些记录么?")) {
document.listform.submit() ; }
}

function add()
{
if ( document.addform.password1.value != document.addform.password2.value )
{alert("两次输入口令不对!")}
else if (confirm("您确认增加这条记录么?")) {
document.addform.submit(); }
}
//-->
</script>
<%

if trim(Request.Form("decidedel")) = "decidedel" then
set conn = server.CreateObject("adodb.connection")
conn.Open session("dsn"),session("sqllogin_1"),session("sqlpassword_1")
for m=1 to session("recordcount")
if trim(Request.Form("check"&m))<> "" then
delsql= "delete tmanager where managerid='"&Request.Form("check"&m)&"'"
conn.Execute delsql,0,1
end if
next
end if

'Response.Write Request.Form("loginname")
if trim(Request.Form("decideadd")) = "decideadd" then
'Response.Write "aaaa"
set conn = server.CreateObject("adodb.connection")
conn.Open session("dsn"),session("sqllogin_1"),session("sqlpassword_1")
set conn1 = server.CreateObject("adodb.connection")
conn1.Open session("dsn"),session("sqllogin_1"),session("sqlpassword_1")
findsql1 = "select * from tmanager where login='"&replace(Request.Form("loginname"),"'","“")&"'"
' Response.Write findsql1
set findrs1 = server.CreateObject("adodb.recordset")
findrs1.Open findsql1,conn1,1
if findrs1.RecordCount = 1 then
%>
<script language='javascript'>
<!--
window.history.back();
alert("管理人员名称重复,请另输入一个!");
-->
</script>
<%
findrs1 = nothing
conn1 = nothing
else
addsql = " insert into tmanager (login,password,class)values('"&replace(trim(Request.Form("loginname")),"'","“")&"','"&replace(trim(Request.Form("password1")),"'","“")&"','"&replace(trim(Request.Form("class")),"'","“")&"') "
'Response.Write addsql
conn.Execute addsql,0,1
end if
end if


set conn = server.CreateObject("adodb.connection")
conn.Open session("dsn"),session("sqllogin_1"),session("sqlpassword_1")
sql = "select * from tmanager "
set rs=server.CreateObject("adodb.recordset")
rs.Open sql,conn,1
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY bgcolor=#F0E68C>

<Center><p class=title>管理人员信息维护<hr></p></Center>

<form name="listform" method="post" action="listmanager.asp">
<input type="hidden" name="decidedel" value="decidedel">
<%
'显示数据
Response.Write "<center>"
Response.Write "<table border=3>"
Response.Write "<tr>"
%>
<P> </P>
<P>
<td bgcolor="#eeeeff">删除</td>
<td bgcolor="#eeeeff">管理人员id</td>
<td bgcolor="#eeeeff">登录名</td>
<td bgcolor="#eeeeff">密码</td>
<td bgcolor="#eeeeff">级别</td>
<%
Response.Write "</tr>"
session("recordcount") = rs.RecordCount
for i=1 to rs.RecordCount
Response.Write "<tr>"
%>
<td bgcolor="#eeeeff" width = 20><input type="checkbox" name="<%="check"&i %>" value=<%=rs("managerid").value%>></td>
<td bgcolor="#eeeeff" width = 170><%=rs("managerid").value%></td>
<td bgcolor="#eeeeff" width = 170> <%=rs("login").value%></td>
<td bgcolor="#eeeeff" width = 170> ****************</td>
<td bgcolor="#eeeeff" width = 120>
<select id=select1 name=select1 size=1 style="HEIGHT: 38px; WIDTH: 110px">
<OPTION value = "1" <%if trim(rs("class").value)="1" then %>selected<%end if%> >*(一星级)</OPTION>
<OPTION value = "2" <%if trim(rs("class").value)="2" then %>selected<%end if%> >**(二星级)</OPTION>
<OPTION value = "3" <%if trim(rs("class").value)="3" then %>selected<%end if%> >***(三星级)</OPTION>
</select>
</td>
<%
Response.Write "</tr>"
rs.MoveNext
next
%>
</table>
<br>
</center>
</form>
</p>

<center>

<form name="addform" method="post" action="listmanager.asp">
<input type="hidden" name="decideadd" value="decideadd">
<table border=1>
<tr>
</tr>
<td bgcolor="#eeeeff">登录名</td>
<td bgcolor="#eeeeff">密码</td>
<td bgcolor="#eeeeff">确认密码</td>
<td bgcolor="#eeeeff">级别</td>
<tr>
<td bgcolor="#eeeeff"><INPUT type="text" name= "loginname" size= 20 maxlength = 16> </td>
<td bgcolor="#eeeeff"><INPUT type="password" name= "password1" size= 20 maxlength = 16> </td>
<td bgcolor="#eeeeff"><INPUT type="password" name= "password2" size= 20 maxlength = 16></td>
<td bgcolor="#eeeeff">
<select id=select1 name="class" size=1 style="HEIGHT: 38px; WIDTH: 110px">
<OPTION value = "1" selected>*(一星级)</OPTION>
<OPTION value = "2" >**(二星级)</OPTION>
<OPTION value = "3" >***(三星级)</OPTION>
</select>

</td>
</tr>
</table>
</form>
</center>
<center>
<INPUT type="button" value="删除" onclick="javascript:del()" id=button1 name=button1>
<INPUT type="button" value="增加" onclick="javascript:add()" id=button2 name=button2>
</center>
</BODY>
</HTML>
  • 打赏
  • 举报
回复
King 2000-03-26
没有什么难度,先在数据库中查找有关资料显示,然后再生成一个表单,这个表单提交到另一个CGI或ASP就可以了。
  • 打赏
  • 举报
回复
相关推荐
发帖
ASP
加入

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
申请成为版主
帖子事件
创建了帖子
2000-03-26 04:22
社区公告
暂无公告