注册 登录
编程论坛 ASP技术论坛

[求助]关于查询程序的问题---谢谢--急!!

红枫叶 发布于 2007-08-17 12:02, 571 次点击

我的技术不好,各位大大别见笑啊!

<ul>
<% set rs = conn.execute("select top 12 * from member where userType>2 and ispass=1 and isdel=0 and islock=0 order by views desc")
if not rs.eof or not rs.bof then
do while not rs.eof
%><li><a rel="external" href="corp/index.asp?id=<%=rs("userid")%>"><%=rs("title")%></a></li>
<% rs.movenext
loop
else
response.write"<li>暂无信息!</li>"
end if
rs.close
set rs=nothing
%>
</ul>


这是原来的代码:有点错误返回的数据没受Top 12 的限制


我想把它修改为:

第一列显示:top12,
第二列显示:13-24,
第三列显示:25-36.
每列宽度为159
每条信息最多显示22个字符
例如:中国联想电脑有限集团责任公司
只显示为:中国联想电脑有限集团责..
但替换:alt="中国联想电脑有限集团责任公司"
如图:


哪位大大能帮忙写一下这段程序啊!

6 回复
#2
红枫叶2007-08-17 12:28

哪位帮帮忙啊。。。
实在是急啊!!!

#3
qhscqb2007-08-17 12:47
这种功能简单地可以用len和left函数通过判断来实现,比较简单。自己再想想,相信你一定能完成。
#4
红枫叶2007-08-17 12:52

我是刚刚接触这个东西,没有系统学习过
这是拿别人的东西在这里改改

麻烦多指点一下,


见笑了

#5
ayue2222007-08-17 12:55
给你个字符串截取的函数 用 gotTopic(str,strlen)调用 如: gotTopic('中国联想电脑有限集团责任公司',10)

function gotTopic(str,strlen)
if str="" or IsNull(str) then
gotTopic=""
exit function
end if
dim l,t,c, i
str=replace(replace(replace(replace(str,"&nbsp;"," "),"&quot;",chr(34)),"&gt;",">"),"&lt;","<")
l=len(str)
t=0
for i=1 to l
c=Abs(Asc(Mid(str,i,1)))
if c>255 then
t=t+2
else
t=t+1
end if
if t>=strlen then
gotTopic=left(str,i)&"..."
exit for
else
gotTopic=str
end if
next
gotTopic=replace(replace(replace(replace(gotTopic," ","&nbsp;"),chr(34),"&quot;"),">","&gt;"),"<","&lt;")
end function
#6
qhscqb2007-08-17 13:05

8楼的仁兄回答正解。
特别说这一句
c>255是指如果是英文字字符,则取两个字符,否则(即为汉字)则取一个字,所以不管是英文还是汉字,都可以截取相同的长度,如aaaa.... 这是测试....

#7
红枫叶2007-08-17 13:10

谢谢各位大大啊。我先去试一下哈

1