5D艺术网首页
商城
|
资讯
|
作品
|
博客
|
教程
|
论坛
登录
注册
加为好友
发短消息
来自:
性别:秘密
最后登录:2008-10-28
http://kafeichong.5d.cn/
首页
|
新闻
|
话题
|
博客
|
相册
|
艺术作品
|
社交关系
|
留言板
|
社交圈
2005/04/14 | [asp]我的一些应用函数(转载cnbruce)
类别(asp)
|
评论
(0)
|
阅读(79)
|
发表于 00:41
3,为很多中小企业写站点,一般产品展示是个大项目,那么做成的页面也就不同。
要不就是横排来几个,要不就是竖排来几个,甚至全站要翻来覆去的搞个好几次,麻烦也很累。
索性写个函数能缓解一下,于是就成了下面
<%
function showpros(tablename,topnum,fildname,loopnum,typenum)
Set rs = Server.CreateObject ("ADODB.Recordset")
sql = "Select top "&topnum&" * from "&tablename
rs.Open sql,conn,1,1
if rs.eof and rs.bof then
response.Write("暂时无该记录")
else
response.Write("<table width='100%'>")
for i=1 to rs.recordcount
if (i mod loopnum=1) then
response.write"<tr>"
end if
select case typenum
case "1"
response.Write("<td><table width='100%'><tr><td bgcolor=red width='50%'>")
response.Write(rs(""&fildname&""))
response.Write("</td><td bgcolor=black>")
response.Write("方式1之"&i&"记录")'此处的“方式1”可以替换显示为其余字段的值
response.Write("</td></tr>")'如果字段比较多,继续添加新个表格行来显示
response.Write("</table></td>")
case "2"
response.Write("<td><table width='100%'><tr><td bgcolor=red>")
response.Write(rs(""&fildname&""))
response.Write("</td></tr>")
response.Write("<tr><td bgcolor=black>")
response.Write("方式2之"&i&"记录")
response.Write("</td></tr>")
response.Write("</table></td>")
end select
if (i mod loopnum=0) then
response.write"</tr>"
end if
rs.movenext
next
response.Write("</table>")
end if
rs.close
Set rs = Nothing
end function
%>
参数说明:showpros(tablename,topnum,fildname,loopnum,typenum)
whichpro为选择何类型的产品种类
topnum表示提取多少条记录
fildname表示调试显示的字段,具体应用的时候可以省去该参数,在函数内部直接使用
loopnum表示显示的循环每行的记录条数
typenum表示循环显示的方法:目前分了两类,横向并列、纵向并列显示同一数据记录行的不同记录
引用示例如下:
<%
if request.form("submit")<>"" then
topnum=request.form("topnum")
loopnum=request.form("loopnum")
typenum=request.form("typenum")
else
topnum=8
loopnum=2
typenum=1
end if
%>
<%call showpros("cn_products",topnum,"p_name",loopnum,typenum)%>
<form action=index.asp method=post>
显示的记录总数:<input name=topnum value=<%=topnum%>>
显示的行循环数:<input name=loopnum value=<%=loopnum%>>
显示的方式类型:<select name=typenum>
<option value="1">方式1</option>
<option value="2">方式2</option>
</select>
<input type=submit name=submit value=Sure>
</form>
0
评论
Comments
日志分类
首页
[223]
javascript
[29]
asp
[62]
常识
[12]
SQL
[8]
文学
[2]
Dreamweaver
[22]
网页设计
[25]
flash
[20]
片言碎语
[21]
php
[6]
web standard
[16]