asp 如何将商品分列显示?望高手指教!
发布网友
发布时间:2024-10-06 20:40
我来回答
共2个回答
热心网友
时间:2024-12-15 05:02
table标签的位置不对,判断也要改一下,具体代码如下
<%
i=0
Set rs=conn.execute("select * from procts where hp='true'")
%>
<body>
<table>
<%
while not rs.eof and i<15
if i mod 3=0 then
response.Write("<tr>")
end if
%>
<td>
<img src="pimg/<%=rs("picture1")%>" width="100" height="150" />
</td>
<%
if i mod 3=2 then
response.Write("</tr>")
end if
i=i+1
rs.movenext
wend %>
</table>
</body>
</html>
<%
rs.close
%>
热心网友
时间:2024-12-15 05:02
sql:要打开数据的查询语句
rows:行数
cols:列数
ipage:显示第几页的数据
isShowBookMark:是否显示书签,如果你使用此函数显示于首页上,设置0--不显示
<%
sub showNews(sql,rows,cols,ipage,isShowBookMark,autoLen)
dim rs,page_size,icol,path
if cols="" or not isNumeric(cols) then cols = 1
if cols<=0 then cols = 1
if rows="" or not isNumeric(rows) then rows = 1
if rows<=0 then rows=1
if ipage="" or not isNumeric(ipage) then ipage=1
if ipage<=0 then ipage=1
if autoLen="" or not isNumeric(autoLen) then autoLen = 20
if autoLen<=0 then autoLen = 20
page_size = cols * rows
set rs = server.CreateObject("ADODB.recordset")
rs.open sql,conn,1,1
response.write "<table width=100% border=0 cellpadding=0 cellspacing=0 id=news>" & VBCRLF
if rs.eof or rs.bof then
response.write "<tr><td width=100% height=50 align=center valign=middle style='color:red'>暂时没有信息!</tr>" & VBCRLF
response.write "</table>" & VBCRLF
exit sub
end if
rs.pageSize = page_size
if int(ipage) > int(rs.pageCount) then ipage = rs.pageCount
rs.absolutePage = ipage
icol = 0
while not rs.eof and int(icol)<int(page_size)
if icol mod cols = 0 then
response.write "<tr>" & VBCRLF
end if
response.write "<td width=" & int(100/cols) & "% height=20 align=left valign=middle>" & VBCRLF
%> ·<a href="readData.asp?id=<%=rs("id")%>&DataType=10001" target="_self"><%=autoCut(rs("title"),autoLen)%></a> <span id="time">[<%=DateValue(rs("post_time"))%>](已阅<%=rs("click_count")%>次)</span>
<%
response.write "</td>" & VBCRLF
icol = icol + 1
if icol mod cols = 0 then
response.write "</tr>" & VBCRLF
end if
rs.movenext
wend
if icol mod cols <> 0 then
response.write "<td colspan=" & int(cols - icol mod cols) & "> </td></tr>" & VBCRLF
end if
response.write "</table>"
if isShowBookMark=1 then
dim reg
set reg = new RegExp
reg.pattern = "[&]*page=[0-9]*"
reg.Global = true
reg.Ignorecase = true
path = reg.replace(request.QueryString,"")
if path="" then
path = "?" & path
else
path = "?" & path & "&"
end if
set reg = nothing
response.Write "<br><div style='font-size:12px;color:black'>" & VBCRLF
response.write "<br>总记录数<span style='color:red'>"&rs.recordCount&"</span> 每页<span style='color:red'>" & page_size & "</span> "
if ipage <= 1 then
response.write "<span style='color:darkgray'>首页 前页</span>"
else
response.write "<a href=" & path & "page=1>首页</a> <a href=" & path & "page="&ipage-1&">前页</a>"
end if
if int(ipage) = int(rs.pageCount) then
response.write "<span style='color:darkgray'> 下页 末页</span>"
else
response.write " <a href=" & path & "page="&ipage+1&">下页</a> <a href=" & path & "page="&rs.pageCount&">末页</a>"
end if
response.write " 第"&ipage&"页 共"&rs.pageCount&"页"
response.write "</div>"
end if
end sub
%>