100分 ASP 求救

hu5265235110 2010-08-23 08:45:44
本人不会ASP

求解这段代码有错吗?  有错的话帮忙修改下

要实现的功能是 获取得到Smallclassname的直    得到直后  将数据查出来

现在这问题是  直得到了 但是数据没有出来。   

在线等待。。。。。。

<%
Smallclassname=Trim(request("Smallclassname"))
%>
<%set rk=server.createobject("adodb.recordset")
rk.open "select * from product where Smallclassname='"&Smallclassname&"' order by UpdateTime desc",conn,1,1
if rk.recordcount=0 then
%>
<td height="26" align="center">暂无商品</td>
</tr>
</table>
<%
else
rk.PageSize =6 '每页记录条数
iCount=rk.RecordCount '记录总数
iPageSize=rk.PageSize
maxpage=rk.PageCount
page=request("page")

if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if

if page<1 then
page=1
elseif page>maxpage then
page=maxpage
end if

rk.AbsolutePage=Page

if page=maxpage then
x=iCount-(maxpage-1)*iPageSize
else
x=iPageSize

end if


%>

<table width="27%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<%
ii=0

For i=1 To x
%>
<td width="33%" valign="top" ><table width="120" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="124" height="153" align="center" valign="middle" style="padding-top:15px;"><table width="751" border="0" cellpadding="0" cellspacing="0" >
<tbody>
<tr>
<td width="129" height="101" align="center" valign="middle" style="border:#CCCCCC solid 1px;" ><a href='ProductShow.asp?BigClassName=<%=rk("BigClassName")%>&SmallClassName=<%=rk("SmallClassName")%>&ID=<%=rk("ID")%>' title='<%=rk("title")%>'><img src="<%=trim(rk("DefaultPicUrl"))%>" width="124" height="124" border="0" /></a></td>
<td width="622" align="left" valign="top" style="padding-left:12px; padding-top:10px;"><table width="600" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="20" class="STYLE1" style="font-weight: bold"><%=Left(rk("title"),19)%></td>
</tr>
<tr>
<td height="20" class="tt">价格范围:<%=Left(rk("price"),19)%></td>
</tr>
<tr>
<td height="20" class="tt">推荐理由:</td>
</tr>
<tr>
<td class="tt"><table width="100%" border="0" cellspacing="0">
<tr>
<td width="77%" style=" line-height:18px; font-size:12px; color:#333333;"><%=Left(rk("content"),99)%></td>
<td width="23%" align="right" valign="bottom"><a href='ProductShow.asp?id=<%=rk("id")%>' title='<%=rk("title")%>'>更多详细 >></a></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="10" colspan="2" align="center" valign="middle" style="border-bottom:#CCCCCC dashed 1px;" > </td>
</tr>
</tbody>
</table></td>
</tr>

</table></td>
<%rk.movenext
ii=ii+1%>
<%if ii mod 1 =0 then%>
</tr>
<tr>
<%end if%>
<% next%>
<td height="0" colspan="2" ></td>
</tr>
</table>
...全文
102 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
李睿_Lee 2010-08-23
  • 打赏
  • 举报
回复
跟踪调试一下不就知道了。
首先,把SQL语句输出来,手工在数据库里查询一下,看看有没有结果。
有结果的话,检查一下For循环里的X的值看看是不是有问题。
beeking111 2010-08-23
  • 打赏
  • 举报
回复
for i = m to n
if pno = cint(m_PageNo) then
response.write " <font color=#00CC00>"&i&"</font>"
else
response.write "<b> <a href='?PageNo="&i&"&"&strParameter&"'><font color=#ff6b02>"&i&"</font></a></b>"
end if
next
Response.Write " "

if int(m_PageNo) < int(m_Page) then
response.write "<a href='?PageNo="&m_PageNo+1&"&"&strParameter&"'><img alt='下一页' src='images/page/PageDown.gif' border=0 width='15' height='14'></a>"
else
response.write "<img alt='下一页' src='images/page/PageDown.gif' border=0 width='15' height='14'>"
end if

hu5265235110 2010-08-23
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 calmcrime 的回复:]
<%
ii=0

For i=1 To x
%>

是不是该
For ii=1 To x
[/Quote]


不对。。。
amu1433 2010-08-23
  • 打赏
  • 举报
回复
<%
Smallclassname=Trim(request("Smallclassname"))'Trim(Request.QueryString(""))或者 .form
%>
<%
set rk=server.createobject("adodb.recordset")
sql="select * from product where Smallclassname='"&Smallclassname&"' order by UpdateTime desc"
Rk.Open SQL,conn,1,1
%>
<td height="26" align="center">暂无商品</td>
</tr>
</table>
<%
if not(rs.bof and rs.eof) then

dim m_RecordCount,m_PageNo,m_Page
m_RecordCount=0 : m_PageNo=0 : m_Page=0
m_PageSize = 9
m_PageNo = Trim(Request.querystring("PageNo"))
m_RecordCount = rs.RecordCount
rs.PageSize = m_PageSize
m_Page = rs.PageCount
if m_PageNo = "" then m_PageNo =1
if cint(m_PageNo) < 1 or cint(m_PageNo) > m_Page then m_PageNo = 1
rs.AbsolutePage = m_PageNo
rc = m_PageSize
re = 1
m_Count = 1
thePage = (m_PageNo-1)*m_PageSize+1
N=0


%>

<table width="27%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<%
ii=0

For i=1 To x
%>
<td width="33%" valign="top" ><table width="120" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="124" height="153" align="center" valign="middle" style="padding-top:15px;"><table width="751" border="0" cellpadding="0" cellspacing="0" >
<tbody>
<tr>
<td width="129" height="101" align="center" valign="middle" style="border:#CCCCCC solid 1px;" ><a href='ProductShow.asp?BigClassName=<%=rk("BigClassName")%>&SmallClassName=<%=rk("SmallClassName")%>&ID=<%=rk("ID")%>' title='<%=rk("title")%>'><img src="<%=trim(rk("DefaultPicUrl"))%>" width="124" height="124" border="0" /></a></td>
<td width="622" align="left" valign="top" style="padding-left:12px; padding-top:10px;"><table width="600" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="20" class="STYLE1" style="font-weight: bold"><%=Left(rk("title"),19)%></td>
</tr>
<tr>
<td height="20" class="tt">价格范围:<%=Left(rk("price"),19)%></td>
</tr>
<tr>
<td height="20" class="tt">推荐理由:</td>
</tr>
<tr>
<td class="tt"><table width="100%" border="0" cellspacing="0">
<tr>
<td width="77%" style=" line-height:18px; font-size:12px; color:#333333;"><%=Left(rk("content"),99)%></td>
<td width="23%" align="right" valign="bottom"><a href='ProductShow.asp?id=<%=rk("id")%>' title='<%=rk("title")%>'>更多详细 >></a></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="10" colspan="2" align="center" valign="middle" style="border-bottom:#CCCCCC dashed 1px;" > </td>
</tr>
</tbody>
</table></td>
</tr>

</table></td>
<%
Rs.Movenext
N=N+1
Next
else
response.write "<br><p align='center'><font color=666666>Null!</font></p><br>"
end if
RS.close
%>



<td height="0" colspan="2" ></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="40" align="center" valign="middle"><% Call ShowPage(m_Parameter)%></td>
</tr>
</table>
<%'这是分页函数
SUB ShowPage(strParameter)
if m_PageNo = "" then m_PageNo =1
if cint(m_PageNo) < 1 or cint(m_PageNo) > m_Page then m_PageNo = 1
Response.write "<table width='100%' border=0 align='center' cellspacing=0>"
Response.write " <tr>"
Response.write " <td width='59%' height=22>"
Response.write " 共"
Response.write " <font color=#EE890A><b>"& m_RecordCount &"</b></font>"
Response.write " 个 每页"
Response.write " <font color=#EE890A><b>"& m_PageSize &"</b></font>"
Response.write " 个,当前第"
Response.write " <font color=#EE890A><b>"& m_PageNo &"</b></font>"
Response.Write " 页/共"
Response.write " <font color=#EE890A><b>"& m_Page &"</b></font>"
Response.write " 页"
Response.write " </td>"
Response.write " <td width='60%' align='right'>"

If m_PageNo > 1 then
response.write "<a href='?Page=1&"&strParameter&"'> <img alt='首页' src='images/page/PageHome.gif' border=0 width='15' height='14'></a>"
Else
response.write "<img alt='首页' src='images/page/PageHome.gif' border=0 width='15' height='14'>"
End if

if m_PageNo > 1 then
response.write "<a href='?PageNo="&m_PageNo-1&"&"&strParameter&"'><img alt='上一页' src='images/page/PageUp.gif' border=0 width='15' height='14'></a>"
else
response.write "<img alt='上一页' src='images/page/PageUp.gif' border=0 width='15' height='14'>"
end if

dim m_PageNumber,m,n,i
m_PageNumber = 4 '数字分页个数+1
if m_PageNo-int(m_PageNumber/2) <= 1 then m = 1 else m = m_PageNo-int(m_PageNumber/2)
if m+m_PageNumber > m_Page then
n = m_Page
if m_Page-m_PageNumber <= 1 then m=1 else m = m_Page - m_PageNumber
else
n = m+m_PageNumber
end if

for i = m to n
if pno = cint(m_PageNo) then
response.write " <font color=#00CC00>"&i&"</font>"
else
response.write "<b> <a href='?PageNo="&i&"&"&strParameter&"'><font color=#ff6b02>"&i&"</font></a></b>"
end if
next
Response.Write " "

if int(m_PageNo) < int(m_Page) then
response.write "<a href='?PageNo="&m_PageNo+1&"&"&strParameter&"'><img alt='下一页' src='images/page/PageDown.gif' border=0 width='15' height='14'></a>"
else
response.write "<img alt='下一页' src='images/page/PageDown.gif' border=0 width='15' height='14'>"
end if

if int(m_PageNo) < int(m_Page) then
response.write "<a href='?PageNo="&m_Page&"&"&strParameter&"'><img alt='末页' src='images/page/PageEnd.gif' border=0 width='15' height='14'></a>"
else
response.write "<img alt='末页' src='images/page/PageEnd.gif' border=0 width='15' height='14'>"
end if
Response.write " </td>"
Response.write " </tr>"
Response.write "</table>"
End Sub
%>

这样写 肯定没有错的 呵呵
001007009 2010-08-23
  • 打赏
  • 举报
回复
<%
ii=0

For i=1 To x
%>

是不是该
For ii=1 To x
hu5265235110 2010-08-23
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 calmcrime 的回复:]
你在查询分析器 里面 运行一下该sql 语句呢

看是否返回值

估计是你 下面程序有误!
[/Quote]

返回有直,
您可以帮我看看哪里出错了吗?
001007009 2010-08-23
  • 打赏
  • 举报
回复
你在查询分析器 里面 运行一下该sql 语句呢

看是否返回值

估计是你 下面程序有误!


hu5265235110 2010-08-23
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 calmcrime 的回复:]
那试一试 啊。!
[/Quote]

还是没数据。。。。
001007009 2010-08-23
  • 打赏
  • 举报
回复
那试一试 啊。!
hu5265235110 2010-08-23
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 calmcrime 的回复:]
不可能哟!
那你改成:
...product where Smallclassname='你确定有的值' ....
[/Quote]

??

直是正确的.
我获取的直和数据库上面的直是一样的。
001007009 2010-08-23
  • 打赏
  • 举报
回复
不可能哟!
那你改成:
...product where Smallclassname='你确定有的值' ....
hu5265235110 2010-08-23
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 calmcrime 的回复:]
是不是 提交的值与数据库的值 不相同

...product where Smallclassname='"&Smallclassname&"' ....
改为...product where Smallclassname like'%"&Smallclassname&"%' ....
[/Quote]

获取的直和数据库的直是正确的.

还是一样的,直没出来.
001007009 2010-08-23
  • 打赏
  • 举报
回复
是不是 提交的值与数据库的值 不相同

...product where Smallclassname='"&Smallclassname&"' ....
改为...product where Smallclassname like'%"&Smallclassname&"%' ....

28,404

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧