如何截取字符串?急急~~~!!!

来源:百度知道 编辑:UC知道 时间:2024/05/08 22:49:00
<table width="100%" border="0" cellspacing="0" cellpadding="3" align="center" style="border:1px #bbbbbb solid">
<sql:query var="retJob" dataSource="${db}" sql="select a.rarea,a.outresume,a.inresume,b.indegree,b.outdegree
from by_resume as a,by_student as b where a.loginame=b.loginame order by a.id DESC limit 0,5"/>
<c:if test="${retJob != null}" >
<c:forEach items="${retJob.rows}" var="job">
<tr height="18" bgcolor="#00CCCC">
<td width="17%" align="left" bgcolor="#FFFfFf" title="所获学位"> 
<c:choose>
<c:when test="${empty job.outdegree}">${job.indegree}</c:when>
<c:otherwise>${job.outdegree}</c:otherwise>
</c:ch

可以用修改sql语句的方法,从数据库中出来就做好了,还可以减少取数的数据量。 下面给你sql server版本的,其它情况方法一样
可用case when 语句,
select mail_id,case when len(title)>16 then left(title,35)+'...' else title end as mail_title from mails
然后再加一个链接,指到查看全文的网页就可以了

php中截取字符串的有substr()语法,比如你要截取一个值123456的前3位,你可以用$a=substr("123456",0,3),"123456"表示你要截取的是哪个值,0表示你从哪位开始截取,这里是从0位开始,3是表示你要截取0位后的几个值,这里是指0位后的3位数值,依次类推就可以了,象你的前面50个值就是$a=substr("$b",0,50),$b值你要截取的那个的原数值..