asp 判断字符串中的字符串的问题
<!--#includefile="c.asp"--><%dimcontent,page,arrcontent,sql,i,channelid,classid,photo...
<!--#include file="c.asp"-->
<%
dim content,page,arrcontent,sql,i,channelid,classid,photoid
photoid=request("photoid")
page=request("page")
set rs=server.createobject("adodb.recordset")
sql="select articleid,channelid,classid,content,title,author,writetime,imageurl,uploadimage,photoid from NC_Article where photoid='"&photoid&"'"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write("<script>alert('错误:\n\n不存在该商品的图片!');</script>")
response.end
else
content=rs("content")
if instr(content,"[page_break]")<=0 then
arrcontent=content
else
arrcontent=split(content,"[page_break]")
maxpage=ubound(arrcontent)+1
if page="" or page="0" then
page="1"
else
page=CInt(page)
end if
if page<1 then page=1
if page>maxpage then page=maxpage
title=rs("title")
Response.Write "<html>" & vbCrLf
Response.Write "<head>" & vbCrLf
Response.Write "<meta name='Generator' content='校园星空图片系统 v1.1.0' />" & vbCrLf
Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=gbk' />" & vbCrLf
response.write "<title>"&title&"</title>" & vbCrLf
Response.Write "<link href='../themes/51sucai/style.css' rel='stylesheet' type='text/css' />" & vbCrLf
Response.Write "<script type='text/javascript' src='../js/common.js'></script>" & vbCrLf
Response.Write "</head>" & vbCrLf
...
response.write "<tr>" & vbCrLf
response.write "<td>" & vbCrLf
response.write "当前位置-首页-查看商品更多图片-->>" & vbCrLf
response.write "</td>" & vbCrLf
response.write "</tr>" & vbCrLf
response.write "</table>" & vbCrLf
response.write "<table style='text-align:center;width:860px;'>" & vbCrLf
response.write "<tr>" & vbCrLf
response.write "<td>" & vbCrLf
response.write arrcontent(page-1) & vbCrLf
response.write "</td>" & vbCrLf
response.write "</tr>" & vbCrLf
response.write "</table>" & vbCrLf
response.write "<table style='text-align:center;width:860px;'>" & vbCrLf
response.write "<tr>" & vbCrLf
response.write "<td><strong>" & vbCrLf
response.write "<a href='showmore.asp?photoid="&photoid&"&page=1'>首页</a> " & vbCrLf
response.write "<a href='showmore.asp?photoid="&photoid&"&page="&page-1&"'>上页</a> " & vbCrLf
response.write "<a href='showmore.asp?photoid="&photoid&"&page="&page+1&"'>下页</a> " & vbCrLf
response.write "<a href='showmore.asp?photoid="&photoid&"&page="&maxpage&"'>末页</a></strong> " & vbCrLf
for i= 0 to maxpage
response.write "<a href='showmore.asp?photoid="&photoid&"&page="&i+1&"'>第"&i+1&"页</a> " & vbCrLf
next
response.write "<br><br>"
...
response.write "</body>" & vbCrLf
response.write "</html>" & vbCrLf
response.end
end if
end if
%>
这个是我的现在的程序,如果当我的content里面没有[page_break]这个字符串的时候,网页就是一片空白,什么也没有,里面必须有才能,正常显示,如何处理
一楼的答案不行,我自己已经试过了,提前结束IF,但是会造成类型不匹配
二楼的,如果去掉判断,里面都没有这个字符,在取截取字符串为数组的时候不出错? 展开
<%
dim content,page,arrcontent,sql,i,channelid,classid,photoid
photoid=request("photoid")
page=request("page")
set rs=server.createobject("adodb.recordset")
sql="select articleid,channelid,classid,content,title,author,writetime,imageurl,uploadimage,photoid from NC_Article where photoid='"&photoid&"'"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write("<script>alert('错误:\n\n不存在该商品的图片!');</script>")
response.end
else
content=rs("content")
if instr(content,"[page_break]")<=0 then
arrcontent=content
else
arrcontent=split(content,"[page_break]")
maxpage=ubound(arrcontent)+1
if page="" or page="0" then
page="1"
else
page=CInt(page)
end if
if page<1 then page=1
if page>maxpage then page=maxpage
title=rs("title")
Response.Write "<html>" & vbCrLf
Response.Write "<head>" & vbCrLf
Response.Write "<meta name='Generator' content='校园星空图片系统 v1.1.0' />" & vbCrLf
Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=gbk' />" & vbCrLf
response.write "<title>"&title&"</title>" & vbCrLf
Response.Write "<link href='../themes/51sucai/style.css' rel='stylesheet' type='text/css' />" & vbCrLf
Response.Write "<script type='text/javascript' src='../js/common.js'></script>" & vbCrLf
Response.Write "</head>" & vbCrLf
...
response.write "<tr>" & vbCrLf
response.write "<td>" & vbCrLf
response.write "当前位置-首页-查看商品更多图片-->>" & vbCrLf
response.write "</td>" & vbCrLf
response.write "</tr>" & vbCrLf
response.write "</table>" & vbCrLf
response.write "<table style='text-align:center;width:860px;'>" & vbCrLf
response.write "<tr>" & vbCrLf
response.write "<td>" & vbCrLf
response.write arrcontent(page-1) & vbCrLf
response.write "</td>" & vbCrLf
response.write "</tr>" & vbCrLf
response.write "</table>" & vbCrLf
response.write "<table style='text-align:center;width:860px;'>" & vbCrLf
response.write "<tr>" & vbCrLf
response.write "<td><strong>" & vbCrLf
response.write "<a href='showmore.asp?photoid="&photoid&"&page=1'>首页</a> " & vbCrLf
response.write "<a href='showmore.asp?photoid="&photoid&"&page="&page-1&"'>上页</a> " & vbCrLf
response.write "<a href='showmore.asp?photoid="&photoid&"&page="&page+1&"'>下页</a> " & vbCrLf
response.write "<a href='showmore.asp?photoid="&photoid&"&page="&maxpage&"'>末页</a></strong> " & vbCrLf
for i= 0 to maxpage
response.write "<a href='showmore.asp?photoid="&photoid&"&page="&i+1&"'>第"&i+1&"页</a> " & vbCrLf
next
response.write "<br><br>"
...
response.write "</body>" & vbCrLf
response.write "</html>" & vbCrLf
response.end
end if
end if
%>
这个是我的现在的程序,如果当我的content里面没有[page_break]这个字符串的时候,网页就是一片空白,什么也没有,里面必须有才能,正常显示,如何处理
一楼的答案不行,我自己已经试过了,提前结束IF,但是会造成类型不匹配
二楼的,如果去掉判断,里面都没有这个字符,在取截取字符串为数组的时候不出错? 展开
2个回答
展开全部
if instr(content,"[page_break]")<=0 then
arrcontent=content
else
arrcontent=split(content,"[page_break]")
end if
maxpage=ubound(arrcontent)+1
if page="" or page="0" then
page="1"
else
page=CInt(page)
end if
if page<1 then page=1
if page>maxpage then page=maxpage
title=rs("title")
Response.Write "<html>" & vbCrLf
Response.Write "<head>" & vbCrLf
Response.Write "<meta name='Generator' content='校园星空图片系统 v1.1.0' />" & vbCrLf
Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=gbk' />" & vbCrLf
response.write "<title>"&title&"</title>" & vbCrLf
Response.Write "<link href='../themes/51sucai/style.css' rel='stylesheet' type='text/css' />" & vbCrLf
Response.Write "<script type='text/javascript' src='../js/common.js'></script>" & vbCrLf
Response.Write "</head>" & vbCrLf
...
response.write "<tr>" & vbCrLf
response.write "<td>" & vbCrLf
response.write "当前位置-首页-查看商品更多图片-->>" & vbCrLf
response.write "</td>" & vbCrLf
response.write "</tr>" & vbCrLf
response.write "</table>" & vbCrLf
response.write "<table style='text-align:center;width:860px;'>" & vbCrLf
response.write "<tr>" & vbCrLf
response.write "<td>" & vbCrLf
response.write arrcontent(page-1) & vbCrLf
response.write "</td>" & vbCrLf
response.write "</tr>" & vbCrLf
response.write "</table>" & vbCrLf
response.write "<table style='text-align:center;width:860px;'>" & vbCrLf
response.write "<tr>" & vbCrLf
response.write "<td><strong>" & vbCrLf
response.write "<a href='showmore.asp?photoid="&photoid&"&page=1'>首页</a> " & vbCrLf
response.write "<a href='showmore.asp?photoid="&photoid&"&page="&page-1&"'>上页</a> " & vbCrLf
response.write "<a href='showmore.asp?photoid="&photoid&"&page="&page+1&"'>下页</a> " & vbCrLf
response.write "<a href='showmore.asp?photoid="&photoid&"&page="&maxpage&"'>末页</a></strong> " & vbCrLf
for i= 0 to maxpage
response.write "<a href='showmore.asp?photoid="&photoid&"&page="&i+1&"'>第"&i+1&"页</a> " & vbCrLf
next
response.write "<br><br>"
...
response.write "</body>" & vbCrLf
response.write "</html>" & vbCrLf
response.end
end if
arrcontent=content
else
arrcontent=split(content,"[page_break]")
end if
maxpage=ubound(arrcontent)+1
if page="" or page="0" then
page="1"
else
page=CInt(page)
end if
if page<1 then page=1
if page>maxpage then page=maxpage
title=rs("title")
Response.Write "<html>" & vbCrLf
Response.Write "<head>" & vbCrLf
Response.Write "<meta name='Generator' content='校园星空图片系统 v1.1.0' />" & vbCrLf
Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=gbk' />" & vbCrLf
response.write "<title>"&title&"</title>" & vbCrLf
Response.Write "<link href='../themes/51sucai/style.css' rel='stylesheet' type='text/css' />" & vbCrLf
Response.Write "<script type='text/javascript' src='../js/common.js'></script>" & vbCrLf
Response.Write "</head>" & vbCrLf
...
response.write "<tr>" & vbCrLf
response.write "<td>" & vbCrLf
response.write "当前位置-首页-查看商品更多图片-->>" & vbCrLf
response.write "</td>" & vbCrLf
response.write "</tr>" & vbCrLf
response.write "</table>" & vbCrLf
response.write "<table style='text-align:center;width:860px;'>" & vbCrLf
response.write "<tr>" & vbCrLf
response.write "<td>" & vbCrLf
response.write arrcontent(page-1) & vbCrLf
response.write "</td>" & vbCrLf
response.write "</tr>" & vbCrLf
response.write "</table>" & vbCrLf
response.write "<table style='text-align:center;width:860px;'>" & vbCrLf
response.write "<tr>" & vbCrLf
response.write "<td><strong>" & vbCrLf
response.write "<a href='showmore.asp?photoid="&photoid&"&page=1'>首页</a> " & vbCrLf
response.write "<a href='showmore.asp?photoid="&photoid&"&page="&page-1&"'>上页</a> " & vbCrLf
response.write "<a href='showmore.asp?photoid="&photoid&"&page="&page+1&"'>下页</a> " & vbCrLf
response.write "<a href='showmore.asp?photoid="&photoid&"&page="&maxpage&"'>末页</a></strong> " & vbCrLf
for i= 0 to maxpage
response.write "<a href='showmore.asp?photoid="&photoid&"&page="&i+1&"'>第"&i+1&"页</a> " & vbCrLf
next
response.write "<br><br>"
...
response.write "</body>" & vbCrLf
response.write "</html>" & vbCrLf
response.end
end if
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询