<%
db="data.asp"
set rs3=server.createobject("adodb.recordset")
set conn3=server.createobject("adodb.connection")
connstr3="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")
conn3.open connstr3
sql3="select * from photo order by id desc"
rs3.open sql3,conn3,1,1
const maxperpage=18
dim sql,rs3,totalput,currentpage,i,listsql,strtype,strp_name,strp_type,strprice_s,strprice_e
rs3.pagesize=maxperpage
if trim(request("page"))<>"" then
currentpage=CLng(request("page"))
if currentpage>rs3.pagecount then
currentpage=rs3.pagecount
end if
else
currentpage=1
end if
if rs3.Eof then
response.write"对不起!还没有任何记录!"
else
totalput=rs3.recordcount
if currentpage<>1 then
if (currentpage-1)*maxperpage<totalput then
rs3.move(currentpage-1)*maxperpage
dim bookmark
bookmark=rs3.bookmark
end if
end if
dim n,k
if (totalput mod maxperpage)=0 then
n=totalput\maxperpage
else
n=totalput\maxperpage+1
end if
%>
<%
k=currentpage
if k<>1 then
response.write"[<b>"+"<a href=xc.asp?page=1>第一页</a></b>]"
response.write"[<b>"+"<a href=xc.asp?page="+cstr(k-1)+">上一页</a></b>]"
else
response.write"[第一页][上一页]"
end if
if k<>n then
response.write"[<b>"+"<a href=xc.asp?page="+cstr(k+1)+">下一页</a></b>]"
response.write"[<b>"+"<a href=xc.asp?page="+cstr(n)+">最后一页</a></b>]"
else
response.write"[下一页][最后一页]"
end if
%>
str=str & "set @sql='select top '+cast(@num as nvarchar(30))+' * from " & tablename
i=1
for each thefieldname in field_info
if i=1 then str=str & " where "
str=str & field_info(thefieldname) & "='+cast(@" & field_info(thefieldname) & " as nvarchar(30))+' and "
i=i+1
next
str=str & theexceptfield & " not in(select top '+cast(@thepage as nvarchar(30))+'" & " " & theexceptfield
str=str & " from " & tablename & " where "
i=1
for each thefieldname in field_info
if i<>1 then str=str & " and "
str=str & field_info(thefieldname) & "='+cast(@" & field_info(thefieldname) & " as nvarchar(30))+'"
i=i+1
next
str=str & "order by " & theexceptfield &") order by " & theexceptfield & "'"
createsqlstr=str
end function
function setfieldnum
set thefieldname=document.getElementById("fieldname")
set thesetnum=document.getElementById("setnum")
thenum=thesetnum.value
if isnumeric(thenum) then
thenum=Cint(thenum)
str="请输入您所要查询的字段名:" & "<br />"
for i=0 to thenum-1
str=str & "字段" & i+1 & ":<input type='text' name='fieldnames' size='30' />" & "<br />"
next
str=str & "请输入您所用的标识字段名:" & "<input type='text' id='exceptfield' />" & "<br />"
str=str & "请输入表明:" & "<input type='text' id='tablenamed' />" & "<br />"
str=str & "<a href='vbscript:saveinfo()'>显示sql</a>"
thefieldname.innerHTML=str
end if
end function
function saveinfo()
set theshowsql=document.getElementById("showsql")
set thefieldnames=document.getElementsByName("fieldnames")
set the_exceptfield=document.getElementById("exceptfield")
set field_info=createobject("scripting.dictionary")
set thetablename=document.getElementById("tablenamed")
theexceptfield=the_exceptfield.value
tablename=thetablename.value
for i=0 to thefieldnames.length-1
thevalue=thefieldnames(i).value
field_info.add thevalue,thevalue
next
str=createsqlstr
theshowsql.innerhtml=str
end function
</script>
<html>
<head>
<base target="_self">
</head>
<body>
设定:<input type='text' id='setnum' size='2' />----<a href='vbscript:setfieldnum()'>确定</a>
<div id='fieldname'>
</div>
<div id='showsql'>
</div>
</body>
</html>