asp中读取数据库时,只取前N位字符,并添加...

 <%
    dim rs,sql,list,i
    sql="select realname,sex,school,myfirstjob,professional,shenfen,shoufei,joindate  from cduserjiaoyuan order by joindate desc"
    easp.db.pagesize=15
    set rs=easp.db.getrs(sql)
    list=rs.getrows()
    for i= 0 To ubound (list,2)
    if len(list(3,i))>10 then   '长度大于10
    list(3,i)=left(list(3,i),10)&"..."   '截取前10位并加上...
    else
    list(3,i)=list(3,i)   '小于10位为本身
    end if
    if list(3,i)="" then    '判断为空是输出值
    list(3,i)="全能教员!"
    end if
    %>
    <tr><td><%=list(0,i)%></td><td><%=list(1,i)%></td><td ><%=list(2,i)%></td><td><%=list(3,i)%></td><td><%=list(4,i)%></td><td><%=list(5,i)%></td><td><%=list(6,i)%></td><td><a href="/jiaoyuaninfo.asp" class="button glow button-rounded button-flat">查看</a></td></tr>
     <% 
      Next
     %>
posted @ 2014-07-31 13:39  Demoworld  阅读(400)  评论(0)    收藏  举报