关于asp查询的问题
关于asp查询的问题
具体请看红色的部分。
我想通过
<form name="form1" method="post" action="s/index.asp">
<input type="text" name="title" size="8">
<input type="submit" name="Submit" value="搜索">
</form>
页面来提交搜索。
index.asp页面如下
<!--#include file="dbconn.asp"-->
<html>
<head>
<title>cdjt</title>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<link rel="stylesheet" type="text/css" href="download.css">
<title>精品斋</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
td { font-family: "宋体"; font-size: 12px}
.button { font-family: "宋体"; font-size: 12px; height: 20px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
.line { line-height: 15pt}
a { text-decoration: none}
a:hover { color: #FF6600; text-decoration: underline}
-->
</style>
</head>
<%
const MaxPerPage=15
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
%>
<body bgcolor="#FFFFFF" topmargin="2" link="#000000" vlink="#333333">
<table width="100%" border="0" cellpadding="0" cellspacing="2">
<tr>
<td width="28%" height="304" valign="top"> <br>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="72%" height="304" valign="top">
<table width="100%" cellspacing="2" cellpadding="2" border="1" bordercolor="#FFFFFF" height="332">
<tr>
<td width="100%" height="105">
<%
dim sql
dim rs
'sql="select * from news order by id desc"
sql="select * from news where title like '%title%'"
<font size='5' color=red>’问题在这里如果我不知道'%title%'写得对不对,和怎么来取得title的值,请高手指点一二。</font>
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "<p align='center'> 还 没 有 任 何 程 序</p>"
else
totalPut=rs.recordcount
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showpage totalput,MaxPerPage,"manage.asp"
showContent
showpage totalput,MaxPerPage,"manage.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showpage totalput,MaxPerPage,"manage.asp"
showContent
showpage totalput,MaxPerPage,"manage.asp"
else
currentPage=1
showpage totalput,MaxPerPage,"manage.asp"
showContent
showpage totalput,MaxPerPage,"manage.asp"
end if
end if
rs.close
end if
set rs=nothing
conn.close
set conn=nothing
sub showContent
dim i
i=0
%>
<div align="center">
<center>
<table border="1" cellspacing="0" width="90%"
bgcolor="#F0F8FF" bordercolorlight="#4DA6FF" bordercolordark="#ECF5FF">
<tr>
<td width="6%" align="center" bgcolor="#0080C0" height="20"><font color="#FFFFFF">ID号</font></td>
<td width="20%" align="center" bgcolor="#0080C0"><font color="#FFFFFF">hpdm</font></td>
<td width="61%" align="center" bgcolor="#0080C0"><font color="#FFFFFF">pmgg</font></td>
<td width="13%" align="center" bgcolor="#0080C0"><font color="#FFFFFF">相关操作</font></td>
</tr>
<%do while not rs.eof%>
<tr>
<td height="2" width="6%">
<p align="center"><%=rs("id")%>
</td>
<td width="20%" height="2"><%=rs("cataid")%></td>
<td width="61%" height="2"><%=rs("title")%></td>
<td width="13%" height="2">
<input type="text" name="textfield" size="4" value="">
</td>
</tr>
<% i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%>
</table>
</center>
</div>
<%
end sub
function showpage(totalnumber,maxperpage,filename)
dim n
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
response.write "<form method=Post action="&filename&">"
response.write "<p align='center'>>>分页 <a href=addfile.asp>增加程式</a> "
if CurrentPage<2 then
response.write "<font color='999966'>首页 上一页</font> "
else
response.write "<a href="&filename&"?page=1>首页</a> "
response.write "<a href="&filename&"?page="¤tPage-1&">上一页</a> "
end if
if n-currentpage<1 then
response.write "<font color='999966'>下一页 尾页</font>"
else
response.write "<a href="&filename&"?page="&(CurrentPage+1)
response.write ">下一页</a> <a href="&filename&"?page="&n&">尾页</a>"
end if
response.write " 页次:<strong><font color=red>"¤tPage&"</font>/"&n&"</strong>页 "
response.write " 共<b>"&totalnumber&"</b>个程式 <b>"&maxperpage&"</b>个程式/页 "
response.write " 转到:<input type='text' name='page' size=4 maxlength=10 class=smallInput value="¤tpage&">"
response.write "<input class=buttonface type='submit' value=' Goto ' name='cndok'></span></p></form>"
end function
%>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>